5 #include <libutl/BidIt.h> 6 #include <libutl/Predicate.h> 7 #include <libutl/algorithms.h> 9 #include <libutl/Mutex.h> 80 virtual void steal(
Object& rhs);
82 virtual void vclone(
const Object& rhs);
100 virtual size_t innerAllocatedSize()
const;
107 virtual bool update(
const Object*
object);
115 return getFlag(flg_owner);
122 setFlag(flg_owner, owner);
147 setOrdering(ordering.clone(), algorithm);
161 return (items() == 0);
168 return getFlag(flg_multiSet);
175 setFlag(flg_multiSet, multiSet);
182 return getFlag(flg_marked);
189 setFlag(flg_marked, marked);
218 return add(
object.
clone());
228 virtual bool add(
const Object*
object) = 0;
237 copyItems(collection);
254 if (isOwner())
return addOrFind(
object.
clone());
255 return addOrFind(&
object);
273 if (isOwner())
return addOrUpdate(
object.
clone());
274 return addOrUpdate(&
object);
283 virtual bool addOrUpdate(
const Object*
object);
304 copyItems(
const ListNode* src,
const Predicate* pred =
nullptr,
bool predVal =
true);
314 copyItems(
const SlistNode* src,
const Predicate* pred =
nullptr,
bool predVal =
true);
381 const char* separator)
const;
428 iterator begin()
const;
434 virtual BidIt* beginNew()
const = 0;
437 virtual BidIt* beginNew() = 0;
440 virtual BidIt* createIt()
const;
443 virtual BidIt* createIt();
446 iterator end()
const;
452 virtual BidIt* endNew()
const = 0;
455 virtual BidIt* endNew() = 0;
469 return contains(*key);
477 bool contains(
const Object& key)
const;
484 size_t count(
const Predicate* pred =
nullptr,
bool predVal =
true)
const;
532 return contains(*key);
539 return contains(key);
549 virtual void clear() = 0;
568 virtual bool remove(
const Object& key);
575 virtual void removeIt(
BidIt& it);
591 return addOrFind(
object);
597 return *addOrFind(
object);
602 virtual void sanityCheck()
const;
604 virtual void addOwnedIt(
const FwdIt* it)
const;
606 virtual bool hasOwnedIt(
const FwdIt* it)
const;
608 virtual void removeOwnedIt(
const FwdIt* it)
const;
610 void exciseOwnedIts()
const;
623 compareObjects(
const Object* lhs,
const Object* rhs)
const 627 return (_ordering ==
nullptr) ? lhs->
compare(*rhs) : _ordering->cmp(lhs, rhs);
640 mutable class RBtree* _ownedIts;
641 mutable class Mutex _ownedItsLock;
T * clone(const T *object)
Create a clone of the given object.
String toString(const FwdIt &begin, const FwdIt &end, const String &sep, bool key=false)
Obtain a string representation of a sequence (via Object::toString()).
void serialize(bool &b, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a boolean.
#define const_cast_this
Pointer to the object the method was invoked on (casting away const).
const Ordering * ordering() const
Get the ordering.
void deInit()
De-initialize UTL++.
Object comparison abstraction.
bool empty() const
Determine whether the collection is empty.
default representation (via getSerializeMode())
Store information about a class.
void add(const Collection &collection)
Add another collection's objects.
bool contains(const Object *key) const
Determine whether the collection contains an object matching the given key.
Mix-in to provide 64-bits for space-efficient storage of up to 64 boolean flags.
Templated proxy for BidIt.
size_t size() const
Get the number of contained objects.
#define IFDEBUG(x)
Do x in DEBUG mode only.
Object * operator[](const Object *object)
add-or-find access operator (returns Object*).
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
void setOrdering(const Ordering &ordering, uint_t algorithm=sort_quickSort)
Set the ordering, and optionally sort the collection to reflect the new ordering. ...
void setMarked(bool marked=true)
Set marked flag.
bool isOwner() const
Get the owner flag.
String toString(const char *sep, bool key=false) const
Obtain a string represenation by invoking Object::toString() on all contained objects (or their keys)...
Logical predicate abstraction.
Forward iterator abstraction.
void setOwner(bool owner)
Set the owner flag.
void findIt(const Object &key, BidIt &it) const
Find an object matching a given key.
bool addOrUpdate(const Object &object)
Add or update the given object.
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).
unsigned int uint_t
Unsigned integer.
const uint_t uint_t_max
Maximum uint_t value.
bool has(const Object *key) const
See contains().
Bi-directional iterator abstraction.
Collection & operator+=(const Collection &rhs)
Add another collection's objects.
size_t items() const
Get the number of contained objects.
bool has(const Object &key) const
See contains().
virtual int compare(const Object &rhs) const
Compare with another object.
void setMultiSet(bool multiSet)
Set the multiSet flag.
bool isMarked() const
Get marked flag.
Object * addOrFind(const Object &object)
Add the given object, or find a matching object already contained.
bool isMultiSet() const
Get the multiSet flag.
Collection & operator-=(const Object &rhs)
Remove an object from the collection.
Object * find(const Object *key) const
Find an object matching a given key.
Object & operator()(const Object *object)
add-or-find access operator (returns Object&).
virtual void serialize(Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize to or from a stream.
Ordering * ordering()
Get the ordering.
Root of UTL++ class hierarchy.
bool add(const Object &object)
Add an object to the collection.
Collection & operator+=(const Object &rhs)
Add an object to the collection.
void dump(const FwdIt &begin, const FwdIt &end, Stream &os, uint_t level=uint_t_max, bool key=false, bool printClassName=false, uint_t indent=0, const char *separator=nullptr)
Dump objects to the given stream (with Object::dump()).
void init()
Initialize UTL++.
#define ASSERTD
Do an assertion in DEBUG mode only.
size_t count(const FwdIt &begin, const FwdIt &end, const Predicate *pred=nullptr, bool predVal=true)
Count objects that satisfy a Predicate.
Collection & operator+=(const Object *rhs)
Add an object to the collection.