libUTL++
slist.h
1 #pragma once
2 
4 
5 #include <libutl/Collection.h>
6 #include <libutl/SlistNode.h>
7 
9 
10 UTL_NS_BEGIN;
11 
13 
21 int slist_compare(const SlistNode* lhs, const SlistNode* rhs, const Ordering* ordering = nullptr);
22 
24 
32 void
33 slist_clone(SlistNode*& outList, SlistNode** outTail, const SlistNode* list, bool owner = true);
34 
36 
46 void slist_serialize(SlistNode*& list,
47  SlistNode** tail,
48  bool owner,
49  Stream& stream,
50  uint_t io,
51  uint_t mode = ser_default);
52 
54 
61 void slist_clear(SlistNode*& list, SlistNode** tail, bool owner = true);
62 
64 
70 size_t slist_items(const SlistNode* list);
71 
73 
79 SlistNode* slist_tail(SlistNode* list);
80 
82 
88 const SlistNode* slist_tail(const SlistNode* list);
89 
91 
100 void slist_add(SlistNode*& list,
101  SlistNode** tail,
102  const Object* object,
103  bool sorted = false,
104  const Ordering* ordering = nullptr);
105 
107 
118 bool slist_remove(SlistNode*& list,
119  SlistNode** tail,
120  const Object& key,
121  bool owner = true,
122  bool sorted = false,
123  const Ordering* ordering = nullptr);
124 
126 
135 void
136 slist_removeNode(SlistNode*& list, SlistNode** tail, SlistNode* node, SlistNode* prev, bool owner);
137 
139 
147 Object* slist_find(SlistNode* list,
148  const Object& key,
149  bool sorted = false,
150  const Ordering* ordering = nullptr);
151 
153 
164 SlistNode* slist_findInsertionPoint(SlistNode* list,
165  const Object& key,
166  bool sorted = false,
167  const Ordering* ordering = nullptr,
168  int* cmpRes = nullptr,
169  SlistNode** prev = nullptr);
170 
172 
182 SlistNode* slist_findNode(SlistNode* list,
183  const Object& key,
184  bool sorted = false,
185  const Ordering* ordering = nullptr,
186  SlistNode** prev = nullptr);
187 
189 
190 UTL_NS_END;
SlistNode * slist_findNode(SlistNode *list, const Object &key, bool sorted=false, const Ordering *ordering=nullptr, SlistNode **prev=nullptr)
Find the node whose object matches the given key.
bool slist_remove(SlistNode *&list, SlistNode **tail, const Object &key, bool owner=true, bool sorted=false, const Ordering *ordering=nullptr)
Remove the object matching the given key from the list.
Object * slist_find(SlistNode *list, const Object &key, bool sorted=false, const Ordering *ordering=nullptr)
Find the object matching the given key in the given list.
default representation (via getSerializeMode())
Definition: util.h:75
SlistNode * slist_findInsertionPoint(SlistNode *list, const Object &key, bool sorted=false, const Ordering *ordering=nullptr, int *cmpRes=nullptr, SlistNode **prev=nullptr)
Find the insertion point for the given key in the given list.
void slist_clear(SlistNode *&list, SlistNode **tail, bool owner=true)
Clear a list.
size_t slist_items(const SlistNode *list)
Count the number of items in a list.
void slist_clone(SlistNode *&outList, SlistNode **outTail, const SlistNode *list, bool owner=true)
Make a copy of a list.
void slist_removeNode(SlistNode *&list, SlistNode **tail, SlistNode *node, SlistNode *prev, bool owner)
Remove the given node from the given list.
void slist_add(SlistNode *&list, SlistNode **tail, const Object *object, bool sorted=false, const Ordering *ordering=nullptr)
Add an object to a list.
void slist_serialize(SlistNode *&list, SlistNode **tail, bool owner, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a list.
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
int slist_compare(const SlistNode *lhs, const SlistNode *rhs, const Ordering *ordering=nullptr)
Compare two lists.
SlistNode * slist_tail(SlistNode *list)
Determine the tail node.