5 #include <libutl/SortedCollection.h> 6 #include <libutl/ListNode.h> 95 List(
bool owner,
bool multiSet =
true,
bool keepSorted =
false,
Ordering* ordering =
nullptr);
97 virtual void steal(
Object& rhs);
99 virtual size_t innerAllocatedSize()
const;
128 return getFlag(flg_keepSorted);
135 return getFlag(flg_sorted);
145 setFlag(flg_keepSorted, keepSorted);
146 if (keepSorted) setFlag(flg_sorted,
true);
154 setOrdering(ordering.clone(), algorithm);
161 setFlag(flg_sorted, sorted);
162 if (!sorted) setFlag(flg_keepSorted,
false);
178 void moveBefore(
const iterator& lhs,
const iterator& rhs);
185 iterator findIt(
const Object& key)
const;
187 iterator findIt(
const Object& key);
209 findFirstIt(
const Object& key,
BidIt& it,
bool insert =
false)
const 215 virtual void findFirstIt(
const Object& key,
BidIt& it,
bool insert =
false);
223 iterator findFirstIt(
const Object& key,
bool insert =
false)
const;
231 iterator findFirstIt(
const Object& key,
bool insert =
false);
240 virtual void findLastIt(
const Object& key,
BidIt& it);
247 iterator findLastIt(
const Object& key)
const;
254 iterator findLastIt(
const Object& key);
262 return super::add(
object);
265 virtual bool add(
const Object*
object);
270 super::add(collection);
278 void addBefore(
const Object*
object,
const iterator& it);
284 isOwner() ? pushFront(
object.
clone()) : pushFront(&
object);
291 isOwner() ? pushBack(
object.
clone()) : pushBack(&
object);
295 void pushFront(
const Object*
object);
298 void pushBack(
const Object*
object);
303 return super::insert(
object, it);
306 virtual void insert(
const Object*
object,
const BidIt& it);
312 virtual void clear();
321 virtual bool remove(
const Object& key);
323 virtual void removeIt(
BidIt& it);
340 inline iterator begin()
const;
342 inline iterator begin();
344 inline virtual BidIt* beginNew()
const;
346 inline virtual BidIt* beginNew();
348 inline iterator end()
const;
350 inline iterator end();
352 inline virtual BidIt* endNew()
const;
354 inline virtual BidIt* endNew();
358 void init(
bool owner =
true,
359 bool multiSet =
true,
360 bool keepSorted =
false,
364 iterator findIt(
const Object& key,
uint_t findType)
const;
387 #include <libutl/TList.h>
void mergeSort(const FwdIt &begin, const FwdIt &end, const Ordering *ordering=nullptr, size_t size=size_t_max)
Merge-sort a sequence.
T * clone(const T *object)
Create a clone of the given object.
bool isSorted() const
Get the sorted flag.
#define const_cast_this
Pointer to the object the method was invoked on (casting away const).
Bi-directional List iterator.
void deInit()
De-initialize UTL++.
void merge(const FwdIt &lhsBegin, const FwdIt &lhsEnd, const FwdIt &rhsBegin, const FwdIt &rhsEnd, FwdIt &out, const Ordering *ordering=nullptr, bool cloning=false)
Merge two sorted sequences into a single sorted sequence.
Object comparison abstraction.
void sort(const FwdIt &begin, const FwdIt &end, const Ordering *ordering=nullptr, uint_t algorithm=sort_quickSort, size_t size=size_t_max)
Sort a sequence using a given algorithm.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Templated proxy for BidIt.
#define IFDEBUG(x)
Do x in DEBUG mode only.
Object * back() const
Return the object at the back of the list (nullptr if none).
Abstraction for a Collection whose objects may be sorted.
void setConst(bool p_const)
Set the const flag.
unsigned int uint_t
Unsigned integer.
void setKeepSorted(bool keepSorted)
Set the keepSorted flag.
void setSorted(bool sorted)
Set the sorted flag.
Bi-directional iterator abstraction.
void insertionSort(const FwdIt &begin, const FwdIt &end, const Ordering *ordering=nullptr, size_t size=size_t_max)
Insertion-sort a sequence.
const ListNode * frontNode() const
Return the front node.
void pushFront(const Object &object)
Add the given object at the front end.
Object * front() const
Return the object at the front of the list (nullptr if none).
Root of UTL++ class hierarchy.
bool isKeptSorted() const
Get the keepSorted flag.
void pushBack(const Object &object)
Add the given object at the back end.
void init()
Initialize UTL++.
#define ASSERTD
Do an assertion in DEBUG mode only.