Hi GetMen, thank you for this interesting idea (as well as for the informative link)!
My question in the first line had not been to save four redundant looking procedures, but to know if there is a more efficient way.
But i wouldn't like to need to change the already existing getter and setters code for the data too much though.
In fact the sample might show up a very amazing approach! Really nice!
I'd need it to adapt it somehow to the different situaton (reconde instead of Item = class). I believe that is possible.
Below a minified picture of the data structure i actually have.
Nicole, thank you! On the fly i've not yet a short sample at hand, but GetMem's demo should be meaningful enough for it.
My data are a bit differently structured (as below). For the data amount, i have to take 0 - 30000 records to sort into account.
The TList Sort works quite fast. I'd say: 20000 items within a virtual listview instantly.
So, in a previous app i had sorted selfmade, but try to avoid now such loops and QuickSorts.
If i can succeed with the transfer to "records" i'll come back to it here.
The data structure roughly is:
type
..
PMyData = ^TMyData;
TMyData = packed record
FName: String[255];
FTime: LongInt;
// etc. etc., others
//SortForward: Boolean; // -> Would be an idea, but not a good idea ....
//FListEx: TListEx; // -> Oh! Could be a good idea i guess .. gives access to the storer of the sortdirection information
end;
... (class:) ...
private
FDataList: TList;
... within Create: ...
FDataList := TList.Create;
procedure DataSetter();
var MyData: PMyData;
begin
GetMem(MyData, SizeOf(TMyData));
MyData^.FName := ..something ..
...
FDataList.Add(MyData);
procedure DataGetter();
var MyData: PMyData; someindex: integer; S: String;
begin
someindex := 17;
MyData := FDataList.Items[someindex];
S := MyData^.FName;