@@ -23,33 +23,33 @@ extern "C" {
2323// Create a new, empty list.
2424CZMQ_EXPORT zlistx_t *
2525 zlistx_new (void );
26-
26+
2727// Destroy a list. If an item destructor was specified, all items in the
2828// list are automatically destroyed as well.
2929CZMQ_EXPORT void
3030 zlistx_destroy (zlistx_t * * self_p );
31-
31+
3232// Add an item to the head of the list. Calls the item duplicator, if any,
3333// on the item. Resets cursor to list head. Returns an item handle on
3434// success, NULL if memory was exhausted.
3535CZMQ_EXPORT void *
3636 zlistx_add_start (zlistx_t * self , void * item );
37-
37+
3838// Add an item to the tail of the list. Calls the item duplicator, if any,
3939// on the item. Resets cursor to list head. Returns an item handle on
4040// success, NULL if memory was exhausted.
4141CZMQ_EXPORT void *
4242 zlistx_add_end (zlistx_t * self , void * item );
43-
43+
4444// Return the number of items in the list
4545CZMQ_EXPORT size_t
4646 zlistx_size (zlistx_t * self );
47-
47+
4848// Return the item at the head of list. If the list is empty, returns NULL.
4949// Leaves cursor pointing at the head item, or NULL if the list is empty.
5050CZMQ_EXPORT void *
5151 zlistx_first (zlistx_t * self );
52-
52+
5353// Return the next item. At the end of the list (or in an empty list),
5454// returns NULL. Use repeated zlistx_next () calls to work through the list
5555// from zlistx_first (). First time, acts as zlistx_first().
@@ -61,7 +61,7 @@ CZMQ_EXPORT void *
6161// backwards from zlistx_last (). First time, acts as zlistx_last().
6262CZMQ_EXPORT void *
6363 zlistx_prev (zlistx_t * self );
64-
64+
6565// Return the item at the tail of list. If the list is empty, returns NULL.
6666// Leaves cursor pointing at the tail item, or NULL if the list is empty.
6767CZMQ_EXPORT void *
@@ -96,14 +96,21 @@ CZMQ_EXPORT void *
9696CZMQ_EXPORT void *
9797 zlistx_detach (zlistx_t * self , void * handle );
9898
99+ // Detach item at the cursor, if any, from the list. The item is not modified,
100+ // and the caller is responsible for destroying it as necessary. Returns item
101+ // that was detached, or null if none was. Moves cursor to previous item, so
102+ // you can detach items while iterating forwards through a list.
103+ CZMQ_EXPORT void *
104+ zlistx_detach_cur (zlistx_t * self );
105+
99106// Delete an item, using its handle. Calls the item destructor is any is
100107// set. If handle is null, deletes the first item on the list. Returns 0
101108// if an item was deleted, -1 if not. If cursor was at item, moves cursor
102109// to previous item, so you can delete items while iterating forwards
103110// through a list.
104111CZMQ_EXPORT int
105112 zlistx_delete (zlistx_t * self , void * handle );
106-
113+
107114// Move an item to the start of the list, via its handle.
108115CZMQ_EXPORT void
109116 zlistx_move_start (zlistx_t * self , void * handle );
@@ -116,13 +123,13 @@ CZMQ_EXPORT void
116123// is set.
117124CZMQ_EXPORT void
118125 zlistx_purge (zlistx_t * self );
119-
126+
120127// Sort the list. If an item comparator was set, calls that to compare
121128// items, otherwise compares on item value. The sort is not stable, so may
122129// reorder equal items.
123130CZMQ_EXPORT void
124131 zlistx_sort (zlistx_t * self );
125-
132+
126133// Create a new node and insert it into a sorted list. Calls the item
127134// duplicator, if any, on the item. If low_value is true, starts searching
128135// from the start of the list, otherwise searches from the end. Use the item
@@ -131,7 +138,7 @@ CZMQ_EXPORT void
131138// list head.
132139CZMQ_EXPORT void *
133140 zlistx_insert (zlistx_t * self , void * item , bool low_value );
134-
141+
135142// Move an item, specified by handle, into position in a sorted list. Uses
136143// the item comparator, if any, to determine the new location. If low_value
137144// is true, starts searching from the start of the list, otherwise searches
@@ -149,7 +156,7 @@ CZMQ_EXPORT zlistx_t *
149156// freed when the list is destroyed.
150157CZMQ_EXPORT void
151158 zlistx_set_destructor (zlistx_t * self , czmq_destructor destructor );
152-
159+
153160// Set a user-defined duplicator for list items; by default items are not
154161// copied when the list is duplicated.
155162CZMQ_EXPORT void
0 commit comments