[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Node to first or last element of a sequential list in module list/xl
From: |
Bruno Haible |
Subject: |
Re: Node to first or last element of a sequential list in module list/xlist |
Date: |
Sat, 03 Apr 2021 18:55:27 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-206-generic; KDE/5.18.0; x86_64; ; ) |
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
- Node to first or last element of a sequential list in module list/xlist, Marc Nieper-Wißkirchen, 2021/04/02
- Re: Node to first or last element of a sequential list in module list/xlist, Bruno Haible, 2021/04/02
- Re: Node to first or last element of a sequential list in module list/xlist, Marc Nieper-Wißkirchen, 2021/04/03
- Re: Node to first or last element of a sequential list in module list/xlist, Bruno Haible, 2021/04/03
- Re: Node to first or last element of a sequential list in module list/xlist, Marc Nieper-Wißkirchen, 2021/04/03
- Re: Node to first or last element of a sequential list in module list/xlist, Bruno Haible, 2021/04/03
- Re: Node to first or last element of a sequential list in module list/xlist, Marc Nieper-Wißkirchen, 2021/04/03
- Re: Node to first or last element of a sequential list in module list/xlist, Bruno Haible, 2021/04/03
- Re: Node to first or last element of a sequential list in module list/xlist, Marc Nieper-Wißkirchen, 2021/04/03
- Re: Node to first or last element of a sequential list in module list/xlist,
Bruno Haible <=
- Message not available
- Re: Node to first or last element of a sequential list in module list/xlist, Bruno Haible, 2021/04/04
- Re: Node to first or last element of a sequential list in module list/xlist, Marc Nieper-Wißkirchen, 2021/04/05