diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-10-24 21:03:43 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-10-24 21:03:43 +0200 |
commit | aab49e5a013c53ae812a143fe41add74e0677a61 (patch) | |
tree | f0c6e1ba7db9991f2bd38c9169f9921bfe5e61d8 /doc/inline_clist.rst | |
parent | df5167db909a88fb8e16dd20b37442495a6ac059 (diff) | |
parent | 532d4a24e2013262dfa41fd85c06a9715c99abf7 (diff) |
Update upstream source from tag 'upstream/4.7'
Update to upstream version '4.7'
with Debian dir d3e11463c915e5c39507206197eb3acd42bb8f5f
Diffstat (limited to 'doc/inline_clist.rst')
-rw-r--r-- | doc/inline_clist.rst | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/doc/inline_clist.rst b/doc/inline_clist.rst new file mode 100644 index 0000000..f7bf138 --- /dev/null +++ b/doc/inline_clist.rst @@ -0,0 +1,59 @@ +================================= +Counted inline doubly-linked list +================================= + +clist is the inline doubly-linked list cousin of the inline doubly-linked list, +extended by a counter to retrieve the number of elements in the list in O(1) +time. This is also why all operations always require the list head. For +traversal of clists, use the corresponding HXlist macros. + +Synopsis +======== + +.. code-block:: c + + #include <libHX/list.h> + + struct HXclist_head { + /* public readonly: */ + unsigned int items; + /* Undocumented fields are considered “private” */ + }; + + HXCLIST_HEAD_INIT(name); + HXCLIST_HEAD(name); + void HXclist_init(struct HXclist_head *head); + void HXclist_unshift(struct HXclist_head *head, struct HXlist_head *new_node); + void HXclist_push(struct HXclist_head *head, struct HXlist_head *new_node); + type HXclist_pop(struct HXclist_head *head, type, member); + type HXclist_shift(struct HXclist_head *head, type, member); + void HXclist_del(struct HXclist_head *head, struct HXlist_chead *node); + +``HXCLIST_HEAD_INIT`` + Macro that expands to the static initializer for a clist. + +``HXCLIST_HEAD`` + Macro that expands to the definition of a clist head, with + initialization. + +``HXclist_init`` + Initializes a clist. This function is generally used when the head has + been allocated from the heap. + +``HXclist_unshift`` + Adds the node to the front of the list. + +``HXclist_push`` + Adds the node to the end of the list. + +``HXclist_pop`` + Removes the last node in the list and returns it. + +``HXclist_shift`` + Removes the first node in the list and returns it. + +``HXclist_del`` + Deletes the node from the list. + +The list count in the clist head is updated whenever a modification is done on +the clist through these functions. |