|
Evo C++ Library v0.5.1
|
#include <evo/set.h>

Associative container with unique values for fast lookup.
| TKey | Set value and value type |
| TSize | Size type to use for size values (must be unsigned integer) – default: SizeT |
Caution: Modifying or resizing a set will shift or invalidate existing iterators using it.
Sets that use a hash/comparison type will have these additional methods (not included in this interface), where T is the hash/compare type used:
const T& get_compare() constT& get_compare()See SetList or SetHash for example.
Ordered sets will have these additional methods (not included in this interface):
Iter iter_lower(const Value& value) constIter iter_upper(const Value& value) constIterM iter_lowerM(const Value& value)IterM iter_upperM(const Value& value)Size remove(const Value& value, Size count)Size remove_range(IterM& start, Size count)Size remove_range(IterM& start, IterM& end)See SetList for example.
List sets will have these additional methods (not included in this interface):
Size item(Size index) constSize removeat(Size index)See SetList for example.
Public Types | |
| typedef void | EvoContainerType |
| typedef TKey | Item |
| Item type (same as Value) More... | |
| typedef IteratorBi< ThisType >::Const | Iter |
| Iterator (const) - IteratorBi. More... | |
| typedef IteratorBi< ThisType > | IterM |
| Iterator (mutable) - IteratorBi. More... | |
| typedef TKey | Key |
| Key type (same as Value) More... | |
| typedef Set< TKey, TSize > | SetBaseType |
| Set base type More... | |
| typedef TSize | Size |
| Size type for size values (must be unsigned integer) – default: SizeT. More... | |
| typedef Set< TKey, TSize > | ThisType |
| This type. More... | |
| typedef TKey | Value |
| Value type. More... | |
Public Member Functions | |
| virtual | ~Set () |
| Destructor. More... | |
| virtual Value & | add (const Value &value, bool update=false)=0 |
| Add or update using given item. More... | |
| template<class T > | |
| Size | addfrom (const T &items, bool update=false) |
| Add items from given list or set. More... | |
| template<class T > | |
| Size | addsplit (const T &str, char delim=',') |
| Split delimited string into set items. More... | |
| const SetBaseType & | asconst () const |
| Explicitly use a const reference to this. More... | |
| IterM | begin () |
| Get iterator at first item (mutable). More... | |
| Iter | begin () const |
| Get iterator at first item (const). More... | |
| virtual Size | capacity () const =0 |
| Get set capacity. More... | |
| virtual SetBaseType & | capacity (Size size)=0 |
| Set capacity for set (modifier). More... | |
| virtual SetBaseType & | capacitymin (Size min)=0 |
| Set capacity to at least given minimum for set (modifier). More... | |
| Iter | cbegin () const |
| Get iterator at first item (const). More... | |
| Iter | cend () const |
| Get iterator at end (const). More... | |
| virtual SetBaseType & | clear ()=0 |
| Clear by removing all items. More... | |
| virtual SetBaseType & | compact () |
| Reduce capacity to fit current size (modifier). More... | |
| virtual bool | contains (const Value &value) const =0 |
| Get whether the set contains the given value. More... | |
| bool | empty () const |
| Get whether set is empty (size is 0). More... | |
| IterM | end () |
| Get iterator at end. More... | |
| Iter | end () const |
| Get iterator at end (const). More... | |
| virtual Value & | get (const Value &value, bool *created=NULL)=0 |
| Get value, create if needed (mutable). More... | |
| Iter | iter (const Value &value) const |
| Find (lookup) iterator for given value (const). More... | |
| IterM | iterM (const Value &value) |
| Find (lookup) iterator for given value (mutable). More... | |
| virtual bool | null () const =0 |
| Get whether set is null. More... | |
| bool | operator!= (const SetBaseType &set) const |
| Inequality operator. More... | |
| SetBaseType & | operator= (const SetBaseType &src) |
| Assignment operator. More... | |
| bool | operator== (const SetBaseType &set) const |
| Equality operator. More... | |
| virtual bool | ordered () const =0 |
| Get whether set is ordered. More... | |
| virtual bool | remove (const Value &value)=0 |
| Find and remove given value. More... | |
| virtual bool | remove (IterM &iter, IteratorDir dir=iterNONE)=0 |
| Remove item using given iterator. More... | |
| SetBaseType & | reserve (Size size) |
| Reserve space for new items. More... | |
| virtual SetBaseType & | set ()=0 |
| Set as null and empty. More... | |
| virtual SetBaseType & | set (const SetBaseType &src)=0 |
| Set as copy of given set. More... | |
| virtual SetBaseType & | setempty ()=0 |
| Set as empty but not null. More... | |
| virtual bool | shared () const =0 |
| Get whether shared. More... | |
| Size | size () const |
| Get set size (number of items). More... | |
| virtual SetBaseType & | unshare ()=0 |
| Make data unique by allocating new buffer, if needed (modifier). More... | |
Protected Member Functions | |
| Set () | |
| Constructor. More... | |
| Set (const ThisType &)=delete | |
| Copy constructor (disabled). More... | |
| virtual const Value * | getiter (IterKey &iterkey, const Value &value) const =0 |
| Used by base class to get data to initialize iterator. More... | |
Protected Attributes | |
| Size | size_ |
| Set size (number of items, automatically updated by concrete set members) More... | |
| typedef void EvoContainerType |
| typedef TKey Item |
Item type (same as Value)
| typedef IteratorBi<ThisType>::Const Iter |
Iterator (const) - IteratorBi.
| typedef IteratorBi<ThisType> IterM |
Iterator (mutable) - IteratorBi.
| typedef TKey Key |
Key type (same as Value)
| typedef Set<TKey,TSize> SetBaseType |
Set base type
| typedef TSize Size |
Size type for size values (must be unsigned integer) – default: SizeT.
| typedef TKey Value |
Value type.
|
inlineprotected |
Constructor.
Used by derived types.
|
inlinevirtual |
Destructor.
Add or update using given item.
| value | Value to add (copied) |
| update | Whether to update existing item, true to overwrite existing item – use when items that compare as equal can have diff metadata |
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
inline |
Add items from given list or set.
| items | List to add items from |
| update | Whether to update existing item, true to overwrite existing items – use when items that compare as equal can have diff metadata |
|
inline |
Split delimited string into set items.
| T | String type to parse – inferred from str parameter |
| str | String to parse |
| delim | Value delimiter to use |
|
inline |
Explicitly use a const reference to this.
|
inline |
|
inline |
Get iterator at first item (const).
|
pure virtual |
Get set capacity.
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
pure virtual |
Set capacity for set (modifier).
| size | New capacity |
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
pure virtual |
Set capacity to at least given minimum for set (modifier).
| min | Minimum capacity |
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
inline |
|
inline |
|
pure virtual |
Clear by removing all items.
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
inlinevirtual |
Reduce capacity to fit current size (modifier).
Reimplemented in SetList< TKey, TCompare, TSize >, and SetList< String >.
|
pure virtual |
Get whether the set contains the given value.
| value | Value to look for |
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
inline |
Get whether set is empty (size is 0).
|
inline |
|
inline |
Get iterator at end (const).
Get value, create if needed (mutable).
| value | Value to use, copied if new value is created |
| created | Stores whether new item was created, if not NULL |
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
Used by base class to get data to initialize iterator.
| iterkey | Set to iterator data, if item found |
| value | Value to find |
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
Find (lookup) iterator for given value (const).
| value | Value to find |
Find (lookup) iterator for given value (mutable).
| value | Value to find |
|
pure virtual |
Get whether set is null.
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
inline |
Inequality operator.
| set | Set to compare to |
|
inline |
Assignment operator.
| src | Source to copy |
|
inline |
Equality operator.
| set | Set to compare to |
|
pure virtual |
Get whether set is ordered.
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
pure virtual |
Find and remove given value.
| value | Value to use |
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
pure virtual |
Remove item using given iterator.
| iter | Iterator position |
| dir | Direction to move iterator to next item, iterNONE for end position |
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, SetList< TKey, TCompare, TSize >, SetList< String >, SetHash< TKey, THash, TSize >, and SetHash< TKey, THash, TSize >.
|
inline |
Reserve space for new items.
| size | Size to reserve |
|
pure virtual |
Set as null and empty.
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
pure virtual |
Set as copy of given set.
| src | Source items |
Implemented in SetList< TKey, TCompare, TSize >, and SetList< String >.
|
pure virtual |
Set as empty but not null.
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
pure virtual |
Get whether shared.
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
inline |
Get set size (number of items).
|
pure virtual |
Make data unique by allocating new buffer, if needed (modifier).
Implemented in SetList< TKey, TCompare, TSize >, SetList< String >, and SetHash< TKey, THash, TSize >.
|
protected |
Set size (number of items, automatically updated by concrete set members)
1.8.13