Originally Posted by
Robert Kosek
Nevermind, this function did it pretty well and pretty quickly too.
That's pretty much a binary memory comparison unless I misunderstand it; Delphi SysUtils unit;
[pascal]begin
result := CompareMem(@a,@b,SizeOf(Vector));
end;[/pascal]
Be careful that this trick is only safe for PACKED records. If a record is not packed, you don't know what is in the alignment fields.
Edit: And as you might expect, it's blazingly fast to boot ... however it seems no faster than the boolean comparison I posted previously.
It requires a procedure call etc. If your vector is 16-bit you could cheat maybe like this:
Code:
type tvector = record
case boolean of
false : (x,y,z:integer); //assume tp 16-bit int!
true : (xandy:longint;z:integer);
end;
And then compare like
(a.xandy=b.xandy) and (a.z=b.z)
Bookmarks