[fpc-pascal] sorting and merging array of records

Sven Barth pascaldragon at googlemail.com
Tue Jan 10 19:13:30 CET 2012


On 10.01.2012 18:15, waldo kitty wrote:
> On 1/10/2012 05:39, Sven Barth wrote:
>>
>> // somewhere else:
>> aList.Sort(@SatDataCompare);
>>
>> What I wrote here might not be perfect, but it should give you a start.
>
> thank you very much! it has definitely given me some ideas... one thing
> that concerns me, though, is that i'm using FPC 2.4.5 console mode...
> this fgl unit is available in this FPC for this line?
>
>  > type
>  > TSatDataList = specialize TFPGList<three_line_data>;

Yes, this feature is available in 2.4.5 (though I would nevertheless 
suggest to you to update to the newly released 2.6.0 :) )

>
>
> the other thing i'm trying to figure out is if i can easily and speedily
> pull portions of the satdata fields for the sort and duplicate
> functions... i'm thinking that it would be faster to expand the record
> into each of its actual fields and fill them during import... i think
> i'd rather copy(x,y,z) to individual record field during import rather
> than pulling the needed fields during the sorting and merging phases...

Yes, that might indeed be faster or better.

You could also try to experiment with TFPGMap if your satellite data has 
a unique key. You specialize it like the following:

type
   TYourMap = specialize TFPGMap<YourKeyType, YourKeyData>;

Where YourKeyType is the type of your key (e.g. String, Integer, etc) 
and YourKeyData is your data record. For more info I'd advice you to 
take a look at the class itself and its parent class TFPSMap, because I 
haven't used that class yet.

>
> and one more trip through the raft of data can adjust the social name
> for the satellite :)
>

Can't you adjust that when reading the data as well?

> i'm trying to figure out how to also work out a method of deleting TLEs
> of birds who are down... another list to process and walk through :P

Are they listed in another file?
If so then I suggest the following: read the file and for each record 
read you search in the list for that satellite and do a 
"YourList.Delete(Index)" where "Index" is your for-loop's counter 
variable (if a satellite is contained more than once in your list I'd 
suggest you to use a downwards counting loop from "YourList.Count - 1 
downto 0" otherwise you'll get "List index out of bounds"-exceptions if 
you access the last elements (depending on how many you deleted). 
Otherwise you can cancel the loop using "Break" again.

>
> thanks again for the info!

You're welcome. That's what we're here for ;)

Regards,
Sven



More information about the fpc-pascal mailing list