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

Set implemented as a hash table.
| TKey | Set key type |
| THash | Hash and comparison type to use |
| TSize | Size type to use for size values (must be unsigned integer) – default: SizeT |
O(1), as long as a good hash function is used (low collisions)C++11:
You can leave the default hashing and comparison type (CompareHash) or specify an alternative.
Caution: Modifying or resizing a set will shift or invalidate existing iterators (and pointers) using it.
Example using a set of numbers
Output:
Public Types | |
| typedef void | EvoContainerType |
| typedef THash | Hash |
| Hashing type – default: CompareHash. More... | |
| 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 SetHash< TKey, THash, TSize > | ThisType |
| This type. More... | |
| typedef TKey | Value |
| Value type. More... | |
Public Member Functions | |
| SetHash () | |
| Constructor. More... | |
| SetHash (const SetBaseType &src) | |
| Copy constructor. More... | |
| SetHash (const ThisType &src) | |
| Copy constructor. More... | |
| SetHash (std::initializer_list< Value > init) | |
| Sequence constructor (C++11). More... | |
| SetHash (ThisType &&src) | |
| Move constructor (C++11). More... | |
| Value & | add (const Value &value, bool update=false) |
| 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 ThisType & | 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... | |
| Size | capacity () const |
| Get set capacity. More... | |
| ThisType & | capacity (Size size) |
| Set hash set capacity (capacity). More... | |
| ThisType & | capacitymin (Size min) |
| Set set capacity to at least given minimum. More... | |
| Iter | cbegin () const |
| Get iterator at first item (const). More... | |
| Iter | cend () const |
| Get iterator at end (const). More... | |
| ThisType & | clear () |
| Clear by removing all items. More... | |
| virtual SetBaseType & | compact () |
| Reduce capacity to fit current size (modifier). More... | |
| bool | contains (const Value &value) const |
| 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... | |
| Value & | get (const Value &value, bool *created=NULL) |
| Get value, create if needed (mutable). More... | |
| const Hash & | get_compare () const |
| Get hash & comparison object being used for hashing and comparisons (const). More... | |
| Hash & | get_compare () |
| Get hash & comparison object being used for hashing and comparisons. 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... | |
| bool | null () const |
| Get whether set is null. More... | |
| bool | operator!= (const SetBaseType &set) const |
| Inequality operator. More... | |
| bool | operator!= (const ThisType &set) const |
| Inequality operator. More... | |
| ThisType & | operator= (ThisType &&src) |
| Move assignment operator (C++11). More... | |
| ThisType & | operator= (const SetBaseType &src) |
| Assignment operator. More... | |
| ThisType & | operator= (const ThisType &src) |
| Assignment operator. More... | |
| bool | operator== (const SetBaseType &set) const |
| Equality operator. More... | |
| bool | operator== (const ThisType &set) const |
| Equality operator. More... | |
| bool | ordered () const |
| Get whether set is ordered. More... | |
| bool | remove (const Value &value) |
| Find and remove given value. More... | |
| bool | remove (typename SetBaseType::IterM &iter, IteratorDir dir=iterNONE) |
| Remove item using given iterator. More... | |
| bool | remove (IterM &iter, IteratorDir dir=iterNONE) |
| Remove item using given iterator. More... | |
| ThisType & | reserve (Size size) |
| Reserve space for new items. More... | |
| virtual SetBaseType & | set (const SetBaseType &src)=0 |
| Set as copy of given set. More... | |
| ThisType & | set () |
| Set as null and empty. More... | |
| ThisType & | set (const SetBaseType &src) |
| Set as copy of given set. More... | |
| ThisType & | set (const ThisType &src) |
| Set as copy of given set. More... | |
| ThisType & | setempty () |
| Set as empty but not null. More... | |
| bool | shared () const |
| Get whether shared. More... | |
| Size | size () const |
| Get set size (number of items). More... | |
| ThisType & | unshare () |
| Make data unique by allocating new buffer, if needed (modifier). More... | |
Protected Member Functions | |
| const Value * | getiter (IterKey &iterkey, const Value &value) const |
| 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 THash Hash |
Hashing type – default: CompareHash.
|
inherited |
Item type (same as Value)
| typedef IteratorBi<ThisType>::Const Iter |
Iterator (const) - IteratorBi.
| typedef IteratorBi<ThisType> IterM |
Iterator (mutable) - IteratorBi.
|
inherited |
Key type (same as Value)
|
inherited |
Set base type
|
inherited |
Size type for size values (must be unsigned integer) – default: SizeT.
|
inherited |
Value type.
|
inline |
Constructor.
|
inline |
Copy constructor.
| src | Source to copy |
Sequence constructor (C++11).
| init | Initializer list, passed as comma-separated values in braces { } |
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 |
Implements Set< TKey, TSize >.
|
inlineinherited |
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 |
|
inlineinherited |
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).
|
inlinevirtual |
Set hash set capacity (capacity).
| size | New suggested capacity |
Implements Set< TKey, TSize >.
Set set capacity to at least given minimum.
| min | Minimum capacity |
Implements Set< TKey, TSize >.
|
inline |
|
inline |
|
inlinevirtual |
Clear by removing all items.
Implements Set< TKey, TSize >.
|
inlinevirtualinherited |
Reduce capacity to fit current size (modifier).
Reimplemented in SetList< TKey, TCompare, TSize >, and SetList< String >.
|
inlinevirtual |
Get whether the set contains the given value.
| value | Value to look for |
Implements Set< TKey, TSize >.
|
inlineinherited |
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 |
Implements Set< TKey, TSize >.
|
inline |
Get hash & comparison object being used for hashing and comparisons (const).
|
inline |
Get hash & comparison object being used for hashing and comparisons.
Used by base class to get data to initialize iterator.
| iterkey | Set to iterator data, if item found |
| value | Value to find |
Implements Set< TKey, TSize >.
Find (lookup) iterator for given value (const).
| value | Value to find |
Find (lookup) iterator for given value (mutable).
| value | Value to find |
|
inlinevirtual |
|
inlineinherited |
Inequality operator.
| set | Set to compare to |
|
inline |
Inequality operator.
| set | Set to compare to |
Move assignment operator (C++11).
| src | Source to move |
|
inline |
Assignment operator.
| src | Source to copy |
Assignment operator.
| src | Source to copy |
|
inlineinherited |
Equality operator.
| set | Set to compare to |
|
inline |
Equality operator.
| set | Set to compare to |
|
inlinevirtual |
Get whether set is ordered.
Implements Set< TKey, TSize >.
|
inlinevirtual |
Find and remove given value.
| value | Value to use |
Implements Set< TKey, TSize >.
|
inlinevirtual |
Remove item using given iterator.
| iter | Iterator position |
| dir | Direction to move iterator to next item, iterNONE for end position |
Implements Set< TKey, TSize >.
|
inlinevirtual |
Remove item using given iterator.
| iter | Iterator position |
| dir | Direction to move iterator to next item, iterNONE for end position |
Implements Set< TKey, TSize >.
Reserve space for new items.
| size | Size to reserve |
|
pure virtualinherited |
Set as copy of given set.
| src | Source items |
Implemented in SetList< TKey, TCompare, TSize >, and SetList< String >.
|
inlinevirtual |
|
inline |
Set as copy of given set.
| src | Source items |
Set as copy of given set.
| src | Source items |
|
inlinevirtual |
|
inlinevirtual |
Get whether shared.
Implements Set< TKey, TSize >.
|
inlineinherited |
Get set size (number of items).
|
inlinevirtual |
Make data unique by allocating new buffer, if needed (modifier).
Implements Set< TKey, TSize >.
|
protectedinherited |
Set size (number of items, automatically updated by concrete set members)
1.8.13