Marc Nieper-Wißkirchen wrote: > > Yes, some algorithms need a second, temporary list. Not all algorithms > > can be written to use the original list, be efficient in O() terms, and > > be implementation-independent. > > Speaking of this, this is not always non-trivial if the dispose function is > not NULL. Consider an algorithm that processes one list to produce a new > one. In the end, the old list shall be removed but the items that have > ended up in the new list shall not be disposed. I guess that the canonical > way to achieve this is to use gl_list_set to overwrite the values in the > old list with dummy values (e.g. NULL) so that they are not freed on > eventual removal.
This is one way to handle the situation. Another way is to have a backing- store of all objects somewhere, in such a way that on the particular gl_list_t the dispose function can be NULL. In other words, complicated algorithms work only on a subset of all objects, and the memory management for the objects is elsewhere in the program. Bruno