On 2/4/2014 5:16 PM, Frederic Da Vitoria wrote:
2014-02-04 waldo kitty <wkitt...@windstream.net
<mailto:wkitt...@windstream.net>>:
[...]
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)...
Just a quick idea which could be completely wrong, but wouldn't it solve your
issue if Compare always returned -1 instead of 0?
no, because i lose (at least) the logging of why the record was tossed out...
see below... it wouldn't help with the duplicate keys being inserted in reverse
order...
Procedure TTLEColl.Insert(Item: Pointer);
var
I : Sw_Integer = 0;
old : Pointer;
foo : integer = 0;
begin
I := 0;
If NOT Search(KeyOf(Item), I) OR Duplicates Then // Item valid
begin
logTLEEntryType('M'); // MERGE this TLE
AtInsert(I, Item); // Insert the item
// Insert(Item); // Insert the item
inc(cur_TLEs_added); // increment the add counter
end
else // otherwise
begin
foo := CompareReal(PTLERec(At(i))^.epoch,PTLERec(Item)^.epoch); //
compare the epochs
case foo of
-1 : begin // replace existing record
logTLEEntryType('U'); // UPDATE this entry
old := At(i); // save existing pointer
first!
AtPut(i, Item); // now put in the new record
dispose(PTLERec(old),done); // dispose old one
inc(cur_TLEs_updtd); // increment the updated
counter
end;
0 : begin // we're tossing this one
out
logTLEEntryType('S'); // this entry is the SAME
dispose(PTLERec(Item),done); // dispose the item
inc(cur_TLEs_same); // increment the same
counter
end;
1 : begin // we're tossing this one
out
logTLEEntryType('N'); // the existing entry is
NEWER
dispose(PTLERec(Item),done); // dispose the item
inc(cur_TLEs_old); // increment the old counter
end;
end; // case
end;
end;
--
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.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal