Base Framework
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
HashSet< TYPE > Class Template Reference

Hash set collection. More...

#include <base/collection/HashSet.h>

Inherits Collection.

Classes

class  HashSetEnumerator
 Hash set enumerator. More...
 
class  HashSetImpl
 
class  Node
 

Public Types

typedef TYPE Value
 
typedef HashSetEnumerator< EnumeratorTraits< Value > > Enumerator
 
typedef HashSetEnumerator< ReadEnumeratorTraits< Value > > ReadEnumerator
 

Public Member Functions

void copyOnWrite ()
 
 HashSet ()
 
 HashSet (std::initializer_list< TYPE > values)
 
 HashSet (MemorySize capacity)
 
 HashSet (const HashSet &copy) noexcept
 
HashSetoperator= (const HashSet &assign) noexcept
 
MemorySize getCapacity () const noexcept
 
MemorySize getSize () const noexcept
 
bool isEmpty () const noexcept
 
bool hasValue (const Value &value) const noexcept
 
bool hasKey (const Value &key) const noexcept
 
void add (const Value &value)
 
void remove (const Value &value)
 
void removeAll ()
 
Enumerator getEnumerator () noexcept
 
ReadEnumerator getReadEnumerator () const noexcept
 
 operator bool () const noexcept
 
HashSetoperator<< (const Value &key)
 
HashSetoperator<< (Value &&key)
 

Public Attributes

Reference< HashSetImplimpl
 

Static Public Attributes

static constexpr MemorySize MINIMUM_CAPACITY = 16
 
static constexpr MemorySize MAXIMUM_CAPACITY = PrimitiveTraits<MemorySize>::MAXIMUM/2
 
static constexpr MemorySize DEFAULT_CAPACITY = 16
 

Detailed Description

template<class TYPE>
class HashSet< TYPE >

Hash set collection.

A hash set implementation.

Version
1.2
Examples
testsuite/HashSet.cpp.

Member Typedef Documentation

◆ Enumerator

template<class TYPE >
typedef HashSetEnumerator<EnumeratorTraits<Value> > HashSet< TYPE >::Enumerator

Modifying enumerator.

◆ ReadEnumerator

template<class TYPE >
typedef HashSetEnumerator<ReadEnumeratorTraits<Value> > HashSet< TYPE >::ReadEnumerator

Non-modifying enumerator.

◆ Value

template<class TYPE >
typedef TYPE HashSet< TYPE >::Value

The type of the value.

Constructor & Destructor Documentation

◆ HashSet() [1/3]

template<class TYPE >
HashSet< TYPE >::HashSet ( )
inline

Initializes an hash set.

◆ HashSet() [2/3]

template<class TYPE >
HashSet< TYPE >::HashSet ( MemorySize  capacity)
inline

Initializes the hash set with the specified initial capacity.

◆ HashSet() [3/3]

template<class TYPE >
HashSet< TYPE >::HashSet ( const HashSet< TYPE > &  copy)
inlinenoexcept

Initializes hash set from another hash set.

Member Function Documentation

◆ add()

template<class TYPE >
void HashSet< TYPE >::add ( const Value value)
inline

Adds the value to the set.

◆ copyOnWrite()

template<class TYPE >
void HashSet< TYPE >::copyOnWrite ( )
inline

Copies the hash set if referenced by multiple automation pointers.

◆ getCapacity()

template<class TYPE >
MemorySize HashSet< TYPE >::getCapacity ( ) const
inlinenoexcept

Returns the capacity of the hash set.

◆ getEnumerator()

template<class TYPE >
Enumerator HashSet< TYPE >::getEnumerator ( )
inlinenoexcept

Returns the enumerator of the hash set.

◆ getReadEnumerator()

template<class TYPE >
ReadEnumerator HashSet< TYPE >::getReadEnumerator ( ) const
inlinenoexcept

Returns the read enumerator of the hash set.

◆ getSize()

template<class TYPE >
MemorySize HashSet< TYPE >::getSize ( ) const
inlinenoexcept

Returns the number of elements in the hash set.

◆ hasKey()

template<class TYPE >
bool HashSet< TYPE >::hasKey ( const Value key) const
inlinenoexcept

Returns true if the specified value is in the set.

◆ hasValue()

template<class TYPE >
bool HashSet< TYPE >::hasValue ( const Value value) const
inlinenoexcept

Returns true if the specified value is in the set.

◆ isEmpty()

template<class TYPE >
bool HashSet< TYPE >::isEmpty ( ) const
inlinenoexcept

Returns true if the hash set is empty.

◆ operator bool()

template<class TYPE >
HashSet< TYPE >::operator bool ( ) const
inlinenoexcept

Returns true is non-empty.

◆ operator<<() [1/2]

template<class TYPE >
HashSet& HashSet< TYPE >::operator<< ( const Value key)
inline

Adds value.

◆ operator<<() [2/2]

template<class TYPE >
HashSet& HashSet< TYPE >::operator<< ( Value &&  key)
inline

Adds value.

◆ operator=()

template<class TYPE >
HashSet& HashSet< TYPE >::operator= ( const HashSet< TYPE > &  assign)
inlinenoexcept

Assignment of hash set by hash set.

◆ remove()

template<class TYPE >
void HashSet< TYPE >::remove ( const Value value)
inline

Removes the specified value from this hash set. Raises InvalidNode if the value doesn't exist in the set.

◆ removeAll()

template<class TYPE >
void HashSet< TYPE >::removeAll ( )
inline

Removes all the values from the hash set.

Member Data Documentation

◆ DEFAULT_CAPACITY

template<class TYPE >
constexpr MemorySize HashSet< TYPE >::DEFAULT_CAPACITY = 16
staticconstexpr

The default capacity.

◆ impl

template<class TYPE >
Reference<HashSetImpl> HashSet< TYPE >::impl

Hash set implementation.

◆ MAXIMUM_CAPACITY

template<class TYPE >
constexpr MemorySize HashSet< TYPE >::MAXIMUM_CAPACITY = PrimitiveTraits<MemorySize>::MAXIMUM/2
staticconstexpr

The maximum capacity.

◆ MINIMUM_CAPACITY

template<class TYPE >
constexpr MemorySize HashSet< TYPE >::MINIMUM_CAPACITY = 16
staticconstexpr

The minimum capacity.