[fpc-pascal] TSortedCollection dupes ordering
waldo kitty
wkitty42 at windstream.net
Tue Feb 4 21:55:21 CET 2014
On 2/4/2014 3:28 PM, Jim Leonard wrote:
> On 2/4/2014 1:40 PM, waldo kitty wrote:
>>
>> i have a TSortedCollection that i'm allowing duplicate keys to be
>> inserted in... the problem that i'm having is that the duplicate keys
>> are in reverse order from how they were inserted...
>
> Sounds like your TSortedCollection.Compare() needs additional logic. It isn't
> doing enough comparisons internally to order things properly.
possibly... i dunno... currently it compares the (pstring) keys only... i
thought about trying to also include a second field (a double) which is used for
the "time stamp" but i don't know how to do that without having to use the key
and this "time stamp" field every time i do anything with the records...
>> i am overriding MyCollection^.Insert because i have additional tasks
>> that need to be done at the time of insertion... without duplicate keys,
>
> Wouldn't it be better to perform your additional tasks before the insertion,
> then call a normal .Insert? Why overload something if there isn't really a need
> to?
i kinda thought about that earlier when i was digging thru the code... IIRC,
insert was overridden because there are cases where the existing record needs to
be replaced (because the new record is newer) using AtPut and the non-added
records must be logged and their reason for not being added (older or same)...
--
NOTE: No off-list assistance is given without prior approval.
Please keep mailing list traffic on the list unless
private contact is specifically requested and granted.
More information about the fpc-pascal
mailing list