Re: Node to first or last element of a sequential list in module list/xlist

2021-04-05 Thread Marc Nieper-Wißkirchen
Hi Bruno, Am Mo., 5. Apr. 2021 um 04:45 Uhr schrieb Bruno Haible : > [Adding back bug-gnulib in CC.] > Thanks! > > Is there a fundamental reason why a list walking algorithm that both > > inserts and removes items is not possible with an arbitrary Gnulib list > > container? Obviously, the

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-04 Thread Bruno Haible
[Adding back bug-gnulib in CC.] Hi Marc, > > 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. > > > > Is there a fundamental reason why a list walking algorithm

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-03 Thread Bruno Haible
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 >

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-03 Thread Marc Nieper-Wißkirchen
Hi Bruno, thank you very much! Am Sa., 3. Apr. 2021 um 18:28 Uhr schrieb Bruno Haible : > Marc Nieper-Wißkirchen wrote: > > For example, given a list of fruits, insert "pear" after each "apple" and > > "peach" before each "apple". This can be easily done through > >

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-03 Thread Bruno Haible
Marc Nieper-Wißkirchen wrote: > For example, given a list of fruits, insert "pear" after each "apple" and > "peach" before each "apple". This can be easily done through > gl_list_add_before/gl_list_add_after/gl_list_next_node without using > invalidated nodes. Now I see what you mean. Quasi

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-03 Thread Marc Nieper-Wißkirchen
Am Sa., 3. Apr. 2021 um 12:14 Uhr schrieb Bruno Haible : > Marc Nieper-Wißkirchen wrote: > > > > > I don't understand. You want to use a list_node_t while adding > nodes to > > > > > the list? This is invalid, since the comments in gl_list.h say: > > > > > > > > > > /* Type representing the

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-03 Thread Bruno Haible
Marc Nieper-Wißkirchen wrote: > > > > I don't understand. You want to use a list_node_t while adding nodes to > > > > the list? This is invalid, since the comments in gl_list.h say: > > > > > > > > /* Type representing the position of an element in the list, in a way > > > > that > > > > is

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-03 Thread Marc Nieper-Wißkirchen
Am Sa., 3. Apr. 2021 um 11:49 Uhr schrieb Bruno Haible : > Marc Nieper-Wißkirchen wrote: > > > I don't understand. You want to use a list_node_t while adding nodes to > > > the list? This is invalid, since the comments in gl_list.h say: > > > > > > /* Type representing the position of an

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-03 Thread Bruno Haible
Marc Nieper-Wißkirchen wrote: > > I don't understand. You want to use a list_node_t while adding nodes to > > the list? This is invalid, since the comments in gl_list.h say: > > > > /* Type representing the position of an element in the list, in a way > > that > > is more adapted to the

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-03 Thread Marc Nieper-Wißkirchen
Hi, Am Sa., 3. Apr. 2021 um 00:49 Uhr schrieb Bruno Haible : > This is useful if the list has to be traversed while nodes are added > > because an iterator cannot be used here. > > I don't understand. You want to use a list_node_t while adding nodes to > the list? This is invalid, since the

Re: Node to first or last element of a sequential list in module list/xlist

2021-04-02 Thread Bruno Haible
Hi Marc, > At the moment, there does not seem to be an easy way to retrieve the node > of the first or the last element in a list. The purpose of the gl_list_node_t is to write algorithms that work efficiently with linked-lists, when it is necessary (for performance) to hold a reference to a

Node to first or last element of a sequential list in module list/xlist

2021-04-02 Thread Marc Nieper-Wißkirchen
Hi! At the moment, there does not seem to be an easy way to retrieve the node of the first or the last element in a list. This is useful if the list has to be traversed while nodes are added because an iterator cannot be used here. What is currently possible is to use get_first/set_first (and