5 #include <libutl/Collection.h> 6 #include <libutl/Ordering.h> 54 addOrFind(
const Object&
object)
56 return super::addOrFind(
object);
62 addOrUpdate(
const Object&
object)
64 return super::addOrUpdate(
object);
67 virtual bool addOrUpdate(
const Object*
object);
78 insert(
object.
clone(), it);
80 return insert(&
object, it);
88 virtual void insert(
const Object*
object,
const BidIt& it);
106 setOrdering(ordering.clone(), algorithm);
160 virtual void findFirstIt(
const Object& key,
BidIt& it,
bool insert =
false);
179 virtual void findLastIt(
const Object& key,
BidIt& it);
239 virtual void removeIt(
BidIt& begin,
const BidIt& end);
272 intersection(rhs,
this);
286 bool multiSet =
false)
const;
396 bool testSorted()
const;
425 virtual void sanityCheck()
const;
429 compareObjects(
const Object* lhs,
const Object* rhs)
const 431 return super::compareObjects(lhs, rhs);
435 void checkInsert(
const Object*
object,
const BidIt& it,
bool sorted)
const;
bool isSubSet(const SortedCollection *rhs) const
Determine whether self is a subset of rhs.
void intersect(const SortedCollection *rhs)
Set self to the intersection of self and rhs.
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
T * clone(const T *object)
Create a clone of the given object.
void intersect(const FwdIt &lhsBegin, const FwdIt &lhsEnd, const FwdIt &rhsBegin, const FwdIt &rhsEnd, FwdIt &out, const Ordering *ordering=nullptr, bool cloning=false, bool multiSet=false, bool outIsLHS=false)
Determine the intersection of two sorted sequences.
#define const_cast_this
Pointer to the object the method was invoked on (casting away const).
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.
bool intersects(const FwdIt &lhsBegin, const FwdIt &lhsEnd, const FwdIt &rhsBegin, const FwdIt &rhsEnd, const Ordering *ordering=nullptr)
Determine whether the intersection of two sorted sequences is non-empty.
void difference(const FwdIt &lhsBegin, const FwdIt &lhsEnd, const FwdIt &rhsBegin, const FwdIt &rhsEnd, FwdIt &out, const Ordering *ordering=nullptr, bool cloning=false, bool outIsLHS=false)
Determine the difference between two sorted sequences.
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.
void multiKeyQuickSort(const FwdIt &begin, const FwdIt &end, bool key=true, bool reverse=false, size_t size=size_t_max)
Multi-key quick-sort a sequence.
void remove(FwdIt &begin, const FwdIt &end, bool cmp=false, const Predicate *pred=nullptr, bool predVal=false)
Remove objects from a sequence.
void findLastIt(const Object &key, BidIt &it) const
Find the last object matching the given key.
void reverse(const BidIt &begin, const BidIt &end)
Reverse a sequence.
SortedCollection & operator-=(const SortedCollection &rhs)
Remove objects that have a match in rhs.
void symmetricDifference(const FwdIt &lhsBegin, const FwdIt &lhsEnd, const FwdIt &rhsBegin, const FwdIt &rhsEnd, FwdIt &out, const Ordering *ordering=nullptr, bool cloning=false)
Determine the symmetric difference of two sorted sequences.
#define IFDEBUG(x)
Do x in DEBUG mode only.
void findFirstIt(const Object &key, BidIt &it, bool insert=false) const
Find the first object matching the given key.
bool operator<=(const SortedCollection *rhs)
Determine whether self is a subset of rhs.
void sort()
Sort the collection using the quicksort algorithm.
Abstraction for a Collection whose objects may be sorted.
size_t intersectCard(const FwdIt &lhsBegin, const FwdIt &lhsEnd, const FwdIt &rhsBegin, const FwdIt &rhsEnd, const Ordering *ordering=nullptr, bool multiSet=false)
Determine the cardinality of the intersection of two sorted sequences.
void setConst(bool p_const)
Set the const flag.
#define UTL_CLASS_DECL_ABC(DC, BC)
Declaration of standard UTL++ functionality for an abstract base class (ABC).
bool isSuperSet(const FwdIt &lhsBegin, const FwdIt &lhsEnd, const FwdIt &rhsBegin, const FwdIt &rhsEnd, const Ordering *ordering=nullptr)
Determine whether the lhs sorted sequence is a superset of the rhs sorted sequence.
unsigned int uint_t
Unsigned integer.
Bi-directional iterator abstraction.
bool operator>=(const SortedCollection *rhs)
Determine whether self is a superset of rhs.
void findEqualRange(const Object &key, BidIt &begin, BidIt &end) const
Find the range elements [begin,end) that match a given key.
bool isSubSet(const FwdIt &lhsBegin, const FwdIt &lhsEnd, const FwdIt &rhsBegin, const FwdIt &rhsEnd, const Ordering *ordering=nullptr)
Determine whether the lhs sorted sequence is a subset of the rhs sorted sequence. ...
virtual void removeIt(BidIt &it)
Remove the object the given iterator points to.
void clobber()
Fake read/write access to all memory.
Root of UTL++ class hierarchy.
int compare(bool lhs, bool rhs)
Compare two boolean values.
void insert(const Object &object, const BidIt &it)
Insert an object before the pointed-to location.
bool isSuperSet(const SortedCollection *rhs) const
Determine whether self is a superset of rhs.
void unique(const FwdIt &begin, const FwdIt &end, FwdIt &out, const Ordering *ordering=nullptr, bool cloning=false, bool outIsSrc=false)
Remove duplicate objects from a sorted sequence.
#define ASSERTD
Do an assertion in DEBUG mode only.
void setOrdering(const Ordering &ordering, uint_t algorithm=sort_quickSort)
Set the ordering, and optionally sort the collection to reflect the new ordering. ...