TList.Sort
От | Mainlander |
---|---|
Тема | TList.Sort |
Дата | |
Msg-id | MPG.19da5eca7165eaee989d3a@news.paradise.net.nz обсуждение исходный текст |
Список | pgsql-general |
I have a class that I designed that contains some objects in its fields, that are derived from the TList class. I want to use the TList Sort procedure to sort the items that are in the derived class. The derived class has an extra field that specifies how to sort the items. The problem I have is in the implementation of the Sort method in the way the class is implemented by Borland. The call to the Sort method must pass in the name of a simple procedure. The procedure call then receives the pointers to the two items that it must return the order of. Why oh why could Borland have not implemented the sort procedure call as an event procedure or allow a method of another object to be passed as the parameter to the Sort call, because I want the sort procedure to be able to read the extra field in my class so that it knows how to carry out the sort. As the sort procedure does not receive any information about the calling object there are various un-OO fudges like global variables necessary to enable the sort procedure to get this information which I would like to eliminate. The TStringList custom sort routine has a means of passing you information about the list in question. Better still is the Compare event handler in the TListView and TTreeView components. Why couldn't TList's sort be implemented like one of these?
В списке pgsql-general по дате отправления: