Example #1
0
func TestSwap(t *testing.T) {
	var part1, part2, opart1, opart2 rg.Particule

	part1.Pos[0] = 5.0
	part1.Pos[1] = 5.0
	part1.Pos[2] = 5.0

	part2.Pos[0] = -340.0
	part2.Pos[1] = -340.0
	part2.Pos[2] = -340.0

	opart1 = part1
	opart2 = part2

	if !rg.Equal(part1, opart1) {
		t.Error("Problem with the Equal test function for part1!")
	}
	if !rg.Equal(part2, opart2) {
		t.Error("Problem with the Equal test function for part2!")
	}

	rg.Swap(&part1, &part2)

	if !rg.Equal(part1, opart2) {
		t.Error("Problem with the Swap function for part1!")
	}
	if !rg.Equal(part2, opart1) {
		t.Error("Problem with the Swap function for part2!")
	}
}
Example #2
0
func (e *Node) setPart() (NbUse int32) {
	NbUse = 0
	for i, _ := range e.Part {
		if e.In(e.Part[i]) {
			rg.Swap(&e.Part[NbUse], &e.Part[i])
			NbUse += 1
		}
	}

	return
}