2014-02-07 waldo kitty <wkitt...@windstream.net>: > On 2/6/2014 1:47 PM, Jim Leonard wrote: > >> On 2/6/2014 11:04 AM, waldo kitty wrote: >> >>> ahh... i see what you are doing... you are passing the pointer to the >>> whole record instead of just the needed key... hummm... i'll have to >>> think about that and how to do it in my app... right now i'm only >>> passing the necessary key because the record is 'large'... but then >>> again... some thought and meditation is necessary ;) >>> >> >> Not much thought required -- a pointer to the record is 4 bytes, no >> matter how >> large the record is. >> > > yep! i realized this when i was going back thru the code cleaning it up > and letting the other side of my brain wander about in its own world ;) > > > In fact, it's probably faster than what you're doing, and more flexible. >> > > i was sending the pointer to field's contents ;) > > [time passes] > > well, i thought i was... my KeyOf routine does a cast using > > PTLERec(Item)^.catnbr > > but my (TLE) compare is apparently only sending the pointer to the catnbr > string because the cast there is simply > > PString(Key1)^ > and > PString(Key2)^ > > the only place i understand that my (TTLEColl) compare is in play is in > > > If NOT Search(KeyOf(Item), I) OR Duplicates Then // Item valid > > from the TTLEColl.Insert routine override that i posted previously... that > Insert routine is taking a pointer to an entire record... > > so now i'm a bit confused but it has been a long day... again... :/
This makes sense... at least in your previous version: I guess catnbr is a string. Compare uses whatever KeyOf returns, and since KeyOf returns the address of a string, Compare handles the keys as such. To compare more than 1 field, the simplest way would be for KeyOf to return the address of the TLERec, which is the behavior of TSortedCollection.KeyOf http://lazarus-ccr.sourceforge.net/docs/rtl/objects/tsortedcollection.keyof.html. So IMO you should simply remove your implementation of KeyOf and edit Compare so that it receives PTLERec and uses the relevant fields instead of a simple string. -- Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal