Types Question

Blitz3D Forums/Blitz3D Programming/Types Question

Stevie G(Posted 2005) [#1]
I'm looking for the most efficient way of comparing all the instances of a type with each other without checking the same cobination twice.

This is how I'd do it with an array. Note that I don't want to have to make an array of types.

Blahs = 10
for b = 1 to Blahs-1
for c = b+1 to Blahs
compare ( b , c )
next
next

Cheers
Stevie


Picklesworth(Posted 2005) [#2]
There may be a more magical way around this...

What are you comparing them for?


Stevie G(Posted 2005) [#3]
It's a custom collision engine ...


DJWoodgate(Posted 2005) [#4]
Use an outer for each loop and an inner while loop to iterate types AFTER the current one while not null...

Type mytype
Field num
End Type

For i=1 To 7 
	m.mytype=New mytype
	m\num=i
Next


For b.mytype=Each mytype
	c.mytype=After b
	While c<>Null
		Print "Comparing "+b\num+","+c\num
		c=After c
	Wend
Next

WaitKey()



Stevie G(Posted 2005) [#5]
Got yee .. will give this a try .. should work.


big10p(Posted 2005) [#6]
Stevie, if this if for 2D, you may be interested in this.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1065