Ocean
|
This class implements a hash set. More...
Public Member Functions | |
HashSet (const HashSet< T > &hashSet) | |
Copy constructor. More... | |
HashSet (HashSet< T > &&hashSet) noexcept | |
Move constructor. More... | |
HashSet (const size_t capacity, const ValueFunction &function=defaultHashFunction) | |
Creates a new hash set object by a given capacity. More... | |
bool | insert (const T &element, const bool oneOnly=true, const bool extendCapacity=true) |
Adds a new element to this hash set. More... | |
bool | insert (T &&element, const bool oneOnly=true, const bool extendCapacity=true) |
Adds (moves) a new element to this hash set. More... | |
bool | remove (const T &element) |
Removes an element from this hash set. More... | |
bool | find (const T &element) const |
Returns whether this hash set holds a given element. More... | |
void | clear () |
Removes all elements from this has set. More... | |
size_t | size () const |
Returns the number of elements this hash set currently holds. More... | |
size_t | capacity () const |
Returns the capacity of this hash set. More... | |
bool | isEmpty () const |
Returns whether this hash set is empty. More... | |
HashSet< T > & | operator= (const HashSet< T > &hashSet) |
Assign operator. More... | |
HashSet< T > & | operator= (HashSet< T > &&hashSet) noexcept |
Move operator. More... | |
Protected Types | |
typedef std::pair< std::pair< size_t, size_t >, T > | Element |
Definition of a pair combining a counter states and an object. More... | |
typedef std::vector< Element > | Elements |
Definition of a vector holding the set objects. More... | |
typedef size_t(* | ValueFunction) (const T &element) |
Definition of a function pointer returning a hash set value. More... | |
Protected Member Functions | |
HashSet (size_t capacity, HashSet< T > &&hashSet) | |
Creates a new hash set by a given hash set. More... | |
bool | isConsistent () const |
Returns whether this hash set is still consistent. More... | |
Static Protected Member Functions | |
static size_t | defaultHashFunction (const T &element) |
Default hash function for elements supporting an cast size_t cast. More... | |
Protected Attributes | |
Elements | setElements |
Hash set elements. More... | |
size_t | setSize |
Number of elements this has set holds. More... | |
ValueFunction | setFunction |
Value function. More... | |
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.