118 template<
class TKey,
class TSize=SizeT>
134 IterKey(Size a=0, Size b=0) : a(a), b(b)
136 IterKey(
const IterKey& src)
137 { memcpy(
this, &src,
sizeof(src)); }
139 typedef Item IterItem;
160 virtual const Value*
getiter(IterKey& iterkey,
const Value& value)
const = 0;
186 virtual SetBaseType&
set() = 0;
194 virtual SetBaseType&
set(
const SetBaseType& src) = 0;
199 virtual SetBaseType&
setempty() = 0;
206 virtual SetBaseType&
clear() = 0;
214 virtual bool ordered()
const = 0;
219 virtual bool null()
const = 0;
225 {
return (size_ == 0); }
238 virtual bool shared()
const = 0;
255 else if (this->
null())
259 else if (size_ ==
set.size_) {
284 virtual bool contains(
const Value& value)
const = 0;
290 {
return Iter(*
this); }
298 {
return IterM(*
this); }
302 {
return Iter(*
this); }
316 Iter
iter(
const Value& value)
const {
318 const Item* item = this->
getiter(iterkey, value);
319 return (item != NULL ?
Iter(*
this, iterkey, (IterItem*)item) :
Iter(*
this,
iterEND));
330 Item* item = (Item*)this->
getiter(iterkey, value);
331 return (item != NULL ?
IterM(*
this, iterkey, (IterItem*)item) :
IterM(*
this,
iterEND));
342 virtual Value&
get(
const Value& value,
bool* created=NULL) = 0;
354 virtual SetBaseType&
unshare() = 0;
401 virtual Value&
add(
const Value& value,
bool update=
false) = 0;
410 Size
addfrom(
const T& items,
bool update=
false) {
411 if (
this != &items) {
412 const Size start_size =
size_;
416 return (size_ - start_size);
435 for (; tok.
next(delim); ++count)
448 virtual bool remove(
const Value& value) = 0;
464 virtual void iterInitMutable() = 0;
465 virtual const IterItem* iterFirst(IterKey& key)
const = 0;
466 virtual const IterItem* iterNext(IterKey& key)
const = 0;
467 virtual const IterItem* iterLast(IterKey& key)
const = 0;
468 virtual const IterItem* iterPrev(IterKey& key)
const = 0;
C convert() const
Convert string to value of given type.
Definition: substring.h:1427
Associative container with unique values for fast lookup.
Definition: set.h:119
virtual bool shared() const =0
Get whether shared.
IteratorBi< ThisType >::Const Iter
Iterator (const) - IteratorBi.
Definition: set.h:142
bool empty() const
Get whether set is empty (size is 0).
Definition: set.h:224
Size addfrom(const T &items, bool update=false)
Add items from given list or set.
Definition: set.h:410
virtual SetBaseType & clear()=0
Clear by removing all items.
IterM iterM(const Value &value)
Find (lookup) iterator for given value (mutable).
Definition: set.h:328
TKey Item
Item type (same as Value)
Definition: set.h:127
Set< TKey, TSize > SetBaseType
Set base type
Definition: set.h:123
Iter end() const
Get iterator at end (const).
Definition: set.h:309
#define EVO_ONCPP11(EXPR)
Compile EXPR only if C++11 support is detected, otherwise this is a no-op.
Definition: sys.h:259
Size size() const
Get set size (number of items).
Definition: set.h:230
virtual bool contains(const Value &value) const =0
Get whether the set contains the given value.
virtual bool null() const =0
Get whether set is null.
SetBaseType & reserve(Size size)
Reserve space for new items.
Definition: set.h:389
IterM begin()
Get iterator at first item (mutable).
Definition: set.h:297
Size size_
Set size (number of items, automatically updated by concrete set members)
Definition: set.h:146
virtual SetBaseType & compact()
Reduce capacity to fit current size (modifier).
Definition: set.h:378
Iter cend() const
Get iterator at end (const).
Definition: set.h:293
virtual const Value * getiter(IterKey &iterkey, const Value &value) const =0
Used by base class to get data to initialize iterator.
IterM end()
Get iterator at end.
Definition: set.h:305
IteratorBi< ThisType > IterM
Iterator (mutable) - IteratorBi.
Definition: set.h:143
virtual bool ordered() const =0
Get whether set is ordered.
Bidirectional iterator.
Definition: iter.h:611
Iter iter(const Value &value) const
Find (lookup) iterator for given value (const).
Definition: set.h:316
const SetBaseType & asconst() const
Explicitly use a const reference to this.
Definition: set.h:168
const SubString & value() const
Get current token value from last call to next().
Definition: strtok.h:42
IteratorDir
Iterator direction value.
Definition: iter.h:27
Set< TKey, TSize > ThisType
This type.
Definition: set.h:122
virtual SetBaseType & unshare()=0
Make data unique by allocating new buffer, if needed (modifier).
Size addsplit(const T &str, char delim=',')
Split delimited string into set items.
Definition: set.h:432
virtual Size capacity() const =0
Get set capacity.
Evo C++ Library namespace.
Definition: alg.h:11
No iterator direction.
Definition: iter.h:28
Iter cbegin() const
Get iterator at first item (const).
Definition: set.h:289
TKey Key
Key type (same as Value)
Definition: set.h:125
TSize Size
Size type for size values (must be unsigned integer) – default: SizeT.
Definition: set.h:124
bool next(char delim)
Find next token using delimiter.
Definition: strtok.h:184
bool operator!=(const SetBaseType &set) const
Inequality operator.
Definition: set.h:275
End iterator position.
Definition: iter.h:23
virtual SetBaseType & setempty()=0
Set as empty but not null.
String forward tokenizer.
Definition: strtok.h:112
TKey Value
Value type.
Definition: set.h:126
virtual ~Set()
Destructor.
Definition: set.h:164
SetBaseType & operator=(const SetBaseType &src)
Assignment operator.
Definition: set.h:178
bool operator==(const SetBaseType &set) const
Equality operator.
Definition: set.h:251
Iter begin() const
Get iterator at first item (const).
Definition: set.h:301
T & min(T &a, T &b)
Returns lowest of given values.
Definition: alg.h:26
Set()
Constructor.
Definition: set.h:149
virtual Value & add(const Value &value, bool update=false)=0
Add or update using given item.
Evo basic types and traits.
virtual SetBaseType & capacitymin(Size min)=0
Set capacity to at least given minimum for set (modifier).