[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Add gl_list_remove_last to list/xlist
From: |
Marc Nieper-Wißkirchen |
Subject: |
Add gl_list_remove_last to list/xlist |
Date: |
Tue, 28 Apr 2020 09:08:53 +0200 |
This is a feature request to add an operation
extern gl_list_node_t gl_list_remove_last (gl_list_t list)
to the list/xlist interface.
This operation would remove the last element of the list and return
the node of the previous element (or NULL if no element remained).
There are at least two reasons why adding such an operation is meaningful:
(1) It is a common operation if the list is used as a stack. Pushing
will be gl_list_add_last, popping will be gl_list_remove_last.
(2) The complexity of removing an arbitrary element in an ARRAY list
is O(n). Removing the last element, however, is only O(1). With an
explicit operation gl_list_remove_last, this can be documented in the
table at the beginning of lib_gl_list.h.
Thanks,
Marc
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Add gl_list_remove_last to list/xlist,
Marc Nieper-Wißkirchen <=