|
Ocean
|
This class implements a hash set. More...
#include <HashSet.h>
Public Member Functions | |
| HashSet (const HashSet< T > &hashSet) | |
| Copy constructor. | |
| HashSet (HashSet< T > &&hashSet) noexcept | |
| Move constructor. | |
| HashSet (const size_t capacity, const ValueFunction &function=defaultHashFunction) | |
| Creates a new hash set object by a given capacity. | |
| bool | insert (const T &element, const bool oneOnly=true, const bool extendCapacity=true) |
| Adds a new element to this hash set. | |
| bool | insert (T &&element, const bool oneOnly=true, const bool extendCapacity=true) |
| Adds (moves) a new element to this hash set. | |
| bool | remove (const T &element) |
| Removes an element from this hash set. | |
| bool | find (const T &element) const |
| Returns whether this hash set holds a given element. | |
| void | clear () |
| Removes all elements from this has set. | |
| size_t | size () const |
| Returns the number of elements this hash set currently holds. | |
| size_t | capacity () const |
| Returns the capacity of this hash set. | |
| bool | isEmpty () const |
| Returns whether this hash set is empty. | |
| HashSet< T > & | operator= (const HashSet< T > &hashSet) |
| Assign operator. | |
| HashSet< T > & | operator= (HashSet< T > &&hashSet) noexcept |
| Move operator. | |
Protected Types | |
| typedef std::pair< std::pair< size_t, size_t >, T > | Element |
| Definition of a pair combining a counter states and an object. | |
| typedef std::vector< Element > | Elements |
| Definition of a vector holding the set objects. | |
| typedef size_t(* | ValueFunction) (const T &element) |
| Definition of a function pointer returning a hash set value. | |
Protected Member Functions | |
| HashSet (size_t capacity, HashSet< T > &&hashSet) | |
| Creates a new hash set by a given hash set. | |
| bool | isConsistent () const |
| Returns whether this hash set is still consistent. | |
Static Protected Member Functions | |
| static size_t | defaultHashFunction (const T &element) |
| Default hash function for elements supporting an cast size_t cast. | |
Protected Attributes | |
| Elements | setElements |
| Hash set elements. | |
| size_t | setSize |
| Number of elements this has set holds. | |
| ValueFunction | setFunction |
| Value function. | |
This class implements a hash set.
| T | The data type that is stored by the hash set |
|
protected |
Definition of a pair combining a counter states and an object.
|
protected |
Definition of a vector holding the set objects.
|
protected |
Definition of a function pointer returning a hash set value.
|
inline |
Copy constructor.
| hashSet | The hash set to copy |
|
inlinenoexcept |
Move constructor.
| hashSet | The hash set to move |
|
explicit |
Creates a new hash set object by a given capacity.
| capacity | Maximal capacity the hash set will support |
| function | Hash function to be used |
|
protected |
Creates a new hash set by a given hash set.
| capacity | The capacity of the new has set, with range [hashSet.size(), infinity) |
| hashSet | The hash set which defines the initial values of this hash set, will be moved |
|
inline |
Returns the capacity of this hash set.
| void Ocean::HashSet< T >::clear | ( | ) |
Removes all elements from this has set.
|
inlinestaticprotected |
Default hash function for elements supporting an cast size_t cast.
| element | Element to return the hash value for |
| bool Ocean::HashSet< T >::find | ( | const T & | element | ) | const |
Returns whether this hash set holds a given element.
| element | Element to be checked |
| bool Ocean::HashSet< T >::insert | ( | const T & | element, |
| const bool | oneOnly = true, |
||
| const bool | extendCapacity = true |
||
| ) |
Adds a new element to this hash set.
| element | Element to be added |
| oneOnly | Adds the element if it does not exist already |
| extendCapacity | True, to extend the capacity if necessary |
| bool Ocean::HashSet< T >::insert | ( | T && | element, |
| const bool | oneOnly = true, |
||
| const bool | extendCapacity = true |
||
| ) |
Adds (moves) a new element to this hash set.
| element | Element to be moved |
| oneOnly | Adds the element if it does not exist already |
| extendCapacity | True, to extend the capacity if necessary |
|
protected |
Returns whether this hash set is still consistent.
|
inline |
Returns whether this hash set is empty.
|
inline |
Assign operator.
| hashSet | The hash set to assign |
|
inlinenoexcept |
Move operator.
| hashSet | The hash set to move |
| bool Ocean::HashSet< T >::remove | ( | const T & | element | ) |
Removes an element from this hash set.
| element | Element to be removed |
|
inline |
Returns the number of elements this hash set currently holds.
|
protected |
Hash set elements.
|
protected |
Value function.
|
protected |
Number of elements this has set holds.