libUTL++
dlist.h
1 #pragma once
2 
4 
5 #include <libutl/ListNode.h>
6 
8 
9 UTL_NS_BEGIN;
10 
18 int list_compare(const ListNode* lhs, const ListNode* rhs, const Ordering* ordering = nullptr);
19 
21 
29 void list_clone(ListNode*& outList, ListNode** outTail, const ListNode* list, bool owner = true);
30 
32 
42 void list_serialize(ListNode*& list,
43  ListNode** tail,
44  bool owner,
45  Stream& stream,
46  uint_t io,
47  uint_t mode = ser_default);
48 
50 
57 void list_clear(ListNode*& list, ListNode** tail, bool owner = true);
58 
60 
66 size_t list_items(const ListNode* list);
67 
69 
75 ListNode* list_tail(ListNode* list);
76 
78 
84 const ListNode* list_tail(const ListNode* list);
85 
87 
96 void list_add(ListNode*& list,
97  ListNode** tail,
98  const Object* object,
99  bool sorted = false,
100  const Ordering* ordering = nullptr);
101 
103 
114 bool list_remove(ListNode*& list,
115  ListNode** tail,
116  const Object& key,
117  bool owner = true,
118  bool sorted = false,
119  const Ordering* ordering = nullptr);
120 
122 
130 void list_removeNode(ListNode*& list, ListNode** tail, ListNode* node, bool owner);
131 
133 
141 Object* list_find(ListNode* list,
142  const Object& key,
143  bool sorted = false,
144  const Ordering* ordering = nullptr);
145 
147 
157 ListNode* list_findInsertionPoint(ListNode* list,
158  const Object& key,
159  bool sorted = false,
160  const Ordering* ordering = nullptr,
161  int* cmpRes = nullptr);
162 
164 
173 ListNode* list_findNode(ListNode* list,
174  const Object& key,
175  bool sorted = false,
176  const Ordering* ordering = nullptr);
177 
179 
180 UTL_NS_END;
void list_clone(ListNode *&outList, ListNode **outTail, const ListNode *list, bool owner=true)
Make a copy of a list.
Object * list_find(ListNode *list, const Object &key, bool sorted=false, const Ordering *ordering=nullptr)
Find the object matching the given key in the given list.
void list_clear(ListNode *&list, ListNode **tail, bool owner=true)
Clear a list.
default representation (via getSerializeMode())
Definition: util.h:75
int list_compare(const ListNode *lhs, const ListNode *rhs, const Ordering *ordering=nullptr)
Compare two lists.
void list_serialize(ListNode *&list, ListNode **tail, bool owner, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a list.
ListNode * list_findNode(ListNode *list, const Object &key, bool sorted=false, const Ordering *ordering=nullptr)
Find the node whose object matches the given key.
size_t list_items(const ListNode *list)
Count the number of items in a list.
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
ListNode * list_findInsertionPoint(ListNode *list, const Object &key, bool sorted=false, const Ordering *ordering=nullptr, int *cmpRes=nullptr)
Find the insertion point for the given key in the given list.
void list_removeNode(ListNode *&list, ListNode **tail, ListNode *node, bool owner)
Remove the given node from the given list.
ListNode * list_tail(ListNode *list)
Determine the tail node.
void list_add(ListNode *&list, ListNode **tail, const Object *object, bool sorted=false, const Ordering *ordering=nullptr)
Add an object to a list.
bool list_remove(ListNode *&list, ListNode **tail, const Object &key, bool owner=true, bool sorted=false, const Ordering *ordering=nullptr)
Remove the object matching the given key from the list.