Embedded Template Library 1.0
unordered_set

Classes

class  etl::unordered_set_exception
 
class  etl::unordered_set_full
 
class  etl::unordered_set_out_of_range
 
class  etl::unordered_set_iterator
 
class  etl::iunordered_set< TKey, THash, TKeyEqual >
 

Functions

template<typename TKey , typename TMapped , typename TKeyCompare >
bool etl::operator== (const etl::iunordered_set< TKey, TMapped, TKeyCompare > &lhs, const etl::iunordered_set< TKey, TMapped, TKeyCompare > &rhs)
 
template<typename TKey , typename TMapped , typename TKeyCompare >
bool etl::operator!= (const etl::iunordered_set< TKey, TMapped, TKeyCompare > &lhs, const etl::iunordered_set< TKey, TMapped, TKeyCompare > &rhs)
 

Detailed Description

A unordered_set with the capacity defined at compile time.


Class Documentation

◆ etl::unordered_set_exception

class etl::unordered_set_exception

Exception for the unordered_set.

Public Member Functions

 unordered_set_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::unordered_set_full

class etl::unordered_set_full

Full exception for the unordered_set.

Public Member Functions

 unordered_set_full (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::unordered_set_exception
 unordered_set_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::unordered_set_out_of_range

class etl::unordered_set_out_of_range

Out of range exception for the unordered_set.

Public Member Functions

 unordered_set_out_of_range (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::unordered_set_exception
 unordered_set_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::unordered_set_iterator

class etl::unordered_set_iterator

Iterator exception for the unordered_set.

Public Member Functions

 unordered_set_iterator (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::unordered_set_exception
 unordered_set_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::iunordered_set

class etl::iunordered_set
template<typename TKey, typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
class etl::iunordered_set< TKey, THash, TKeyEqual >

The base class for specifically sized unordered_set. Can be used as a reference type for all unordered_set containing a specific type.

Public Types

typedef TKey value_type
 
typedef TKey key_type
 
typedef THash hasher
 
typedef TKeyEqual key_equal
 
typedef value_type & reference
 
typedef const value_type & const_reference
 
typedef value_type * pointer
 
typedef const value_type * const_pointer
 
typedef size_t size_type
 
typedef const TKey & key_parameter_t
 
typedef etl::forward_link< 0 > link_t
 
typedef bucket_t::iterator local_iterator
 
typedef bucket_t::const_iterator const_local_iterator
 
typedef etl::iterator_traits< iterator >::difference_type difference_type
 

Public Member Functions

iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
local_iterator begin (size_t i)
 
const_local_iterator begin (size_t i) const
 
const_local_iterator cbegin (size_t i) const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
local_iterator end (size_t i)
 
const_local_iterator end (size_t i) const
 
const_local_iterator cend (size_t i) const
 
size_type get_bucket_index (key_parameter_t key) const
 
size_type bucket_size (key_parameter_t key) const
 
size_type max_bucket_count () const
 
size_type bucket_count () const
 
template<typename TIterator >
void assign (TIterator first_, TIterator last_)
 
ETL_OR_STD::pair< iterator, bool > insert (const_reference key)
 
iterator insert (const_iterator, const_reference key)
 
template<class TIterator >
void insert (TIterator first_, TIterator last_)
 
size_t erase (key_parameter_t key)
 
iterator erase (const_iterator ielement)
 
iterator erase (const_iterator first_, const_iterator last_)
 
void clear ()
 Clears the unordered_set.
 
size_t count (key_parameter_t key) const
 
iterator find (key_parameter_t key)
 
const_iterator find (key_parameter_t key) const
 
ETL_OR_STD::pair< iterator, iteratorequal_range (key_parameter_t key)
 
ETL_OR_STD::pair< const_iterator, const_iteratorequal_range (key_parameter_t key) const
 
size_type size () const
 Gets the size of the unordered_set.
 
size_type max_size () const
 Gets the maximum possible size of the unordered_set.
 
size_type capacity () const
 Gets the maximum possible size of the unordered_set.
 
bool empty () const
 Checks to see if the unordered_set is empty.
 
bool full () const
 Checks to see if the unordered_set is full.
 
size_t available () const
 
float load_factor () const
 
hasher hash_function () const
 
key_equal key_eq () const
 
iunordered_setoperator= (const iunordered_set &rhs)
 Assignment operator.
 

Protected Types

typedef etl::intrusive_forward_list< node_t, link_tbucket_t
 
typedef etl::ipool pool_t
 

Protected Member Functions

 iunordered_set (pool_t &node_pool_, bucket_t *pbuckets_, size_t number_of_buckets_, hasher key_hash_function_, key_equal key_equal_function_)
 Constructor.
 
void initialise ()
 Initialise the unordered_set.
 
 ~iunordered_set ()
 For library debugging purposes only. More...
 

Friends

bool operator== (const node_t &lhs, const node_t &rhs)
 
bool operator!= (const node_t &lhs, const node_t &rhs)
 

Constructor & Destructor Documentation

◆ ~iunordered_set()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
etl::iunordered_set< TKey, THash, TKeyEqual >::~iunordered_set ( )
inlineprotected

For library debugging purposes only.

Destructor.

Member Function Documentation

◆ assign()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
template<typename TIterator >
void etl::iunordered_set< TKey, THash, TKeyEqual >::assign ( TIterator  first_,
TIterator  last_ 
)
inline

Assigns values to the unordered_set. If asserts or exceptions are enabled, emits unordered_set_full if the unordered_set does not have enough free space. If asserts or exceptions are enabled, emits unordered_set_iterator if the iterators are reversed.

Parameters
firstThe iterator to the first element.
lastThe iterator to the last element + 1.

◆ available()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
size_t etl::iunordered_set< TKey, THash, TKeyEqual >::available ( ) const
inline

Returns the remaining capacity.

Returns
The remaining capacity.

◆ begin() [1/4]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
iterator etl::iunordered_set< TKey, THash, TKeyEqual >::begin ( )
inline

Returns an iterator to the beginning of the unordered_set.

Returns
An iterator to the beginning of the unordered_set.

◆ begin() [2/4]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::begin ( ) const
inline

Returns a const_iterator to the beginning of the unordered_set.

Returns
A const iterator to the beginning of the unordered_set.

◆ begin() [3/4]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
local_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::begin ( size_t  i)
inline

Returns an iterator to the beginning of the unordered_set bucket.

Returns
An iterator to the beginning of the unordered_set bucket.

◆ begin() [4/4]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_local_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::begin ( size_t  i) const
inline

Returns a const_iterator to the beginning of the unordered_set bucket.

Returns
A const iterator to the beginning of the unordered_set bucket.

◆ bucket_count()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
size_type etl::iunordered_set< TKey, THash, TKeyEqual >::bucket_count ( ) const
inline

Returns the number of the buckets the container holds.

Returns
The number of the buckets the container holds.

◆ bucket_size()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
size_type etl::iunordered_set< TKey, THash, TKeyEqual >::bucket_size ( key_parameter_t  key) const
inline

Returns the size of the bucket key.

Returns
The bucket size of the bucket key.

◆ cbegin() [1/2]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::cbegin ( ) const
inline

Returns a const_iterator to the beginning of the unordered_set.

Returns
A const iterator to the beginning of the unordered_set.

◆ cbegin() [2/2]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_local_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::cbegin ( size_t  i) const
inline

Returns a const_iterator to the beginning of the unordered_set bucket.

Returns
A const iterator to the beginning of the unordered_set bucket.

◆ cend() [1/2]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::cend ( ) const
inline

Returns a const_iterator to the end of the unordered_set.

Returns
A const iterator to the end of the unordered_set.

◆ cend() [2/2]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_local_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::cend ( size_t  i) const
inline

Returns a const_iterator to the end of the unordered_set bucket.

Returns
A const iterator to the end of the unordered_set bucket.

◆ count()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
size_t etl::iunordered_set< TKey, THash, TKeyEqual >::count ( key_parameter_t  key) const
inline

Counts an element.

Parameters
keyThe key to search for.
Returns
1 if the key exists, otherwise 0.

◆ end() [1/4]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
iterator etl::iunordered_set< TKey, THash, TKeyEqual >::end ( )
inline

Returns an iterator to the end of the unordered_set.

Returns
An iterator to the end of the unordered_set.

◆ end() [2/4]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::end ( ) const
inline

Returns a const_iterator to the end of the unordered_set.

Returns
A const iterator to the end of the unordered_set.

◆ end() [3/4]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
local_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::end ( size_t  i)
inline

Returns an iterator to the end of the unordered_set bucket.

Returns
An iterator to the end of the unordered_set bucket.

◆ end() [4/4]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_local_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::end ( size_t  i) const
inline

Returns a const_iterator to the end of the unordered_set bucket.

Returns
A const iterator to the end of the unordered_set bucket.

◆ equal_range() [1/2]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
ETL_OR_STD::pair< iterator, iterator > etl::iunordered_set< TKey, THash, TKeyEqual >::equal_range ( key_parameter_t  key)
inline

Returns a range containing all elements with key 'key' in the container. The range is defined by two iterators, the first pointing to the first element of the wanted range and the second pointing past the last element of the range.

Parameters
keyThe key to search for.
Returns
An iterator pair to the range of elements if the key exists, otherwise end().

◆ equal_range() [2/2]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
ETL_OR_STD::pair< const_iterator, const_iterator > etl::iunordered_set< TKey, THash, TKeyEqual >::equal_range ( key_parameter_t  key) const
inline

Returns a range containing all elements with key 'key' in the container. The range is defined by two iterators, the first pointing to the first element of the wanted range and the second pointing past the last element of the range.

Parameters
keyThe key to search for.
Returns
A const iterator pair to the range of elements if the key exists, otherwise end().

◆ erase() [1/3]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
iterator etl::iunordered_set< TKey, THash, TKeyEqual >::erase ( const_iterator  first_,
const_iterator  last_ 
)
inline

Erases a range of elements. The range includes all the elements between first and last, including the element pointed by first, but not the one pointed to by last.

Parameters
firstIterator to the first element.
lastIterator to the last element.

◆ erase() [2/3]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
iterator etl::iunordered_set< TKey, THash, TKeyEqual >::erase ( const_iterator  ielement)
inline

Erases an element.

Parameters
ielementIterator to the element.

◆ erase() [3/3]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
size_t etl::iunordered_set< TKey, THash, TKeyEqual >::erase ( key_parameter_t  key)
inline

Erases an element.

Parameters
keyThe key to erase.
Returns
The number of elements erased. 0 or 1.

◆ find() [1/2]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
iterator etl::iunordered_set< TKey, THash, TKeyEqual >::find ( key_parameter_t  key)
inline

Finds an element.

Parameters
keyThe key to search for.
Returns
An iterator to the element if the key exists, otherwise end().

◆ find() [2/2]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
const_iterator etl::iunordered_set< TKey, THash, TKeyEqual >::find ( key_parameter_t  key) const
inline

Finds an element.

Parameters
keyThe key to search for.
Returns
An iterator to the element if the key exists, otherwise end().

◆ get_bucket_index()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
size_type etl::iunordered_set< TKey, THash, TKeyEqual >::get_bucket_index ( key_parameter_t  key) const
inline

Returns the bucket index for the key.

Returns
The bucket index for the key.

◆ hash_function()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
hasher etl::iunordered_set< TKey, THash, TKeyEqual >::hash_function ( ) const
inline

Returns the function that hashes the keys.

Returns
The function that hashes the keys..

◆ insert() [1/3]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
iterator etl::iunordered_set< TKey, THash, TKeyEqual >::insert ( const_iterator  ,
const_reference  key 
)
inline

Inserts a value to the unordered_set. If asserts or exceptions are enabled, emits unordered_set_full if the unordered_set is already full.

Parameters
positionThe position to insert at.
valueThe value to insert.

◆ insert() [2/3]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
ETL_OR_STD::pair< iterator, bool > etl::iunordered_set< TKey, THash, TKeyEqual >::insert ( const_reference  key)
inline

Inserts a value to the unordered_set. If asserts or exceptions are enabled, emits unordered_set_full if the unordered_set is already full.

Parameters
valueThe value to insert.

◆ insert() [3/3]

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
template<class TIterator >
void etl::iunordered_set< TKey, THash, TKeyEqual >::insert ( TIterator  first_,
TIterator  last_ 
)
inline

Inserts a range of values to the unordered_set. If asserts or exceptions are enabled, emits unordered_set_full if the unordered_set does not have enough free space.

Parameters
positionThe position to insert at.
firstThe first element to add.
lastThe last + 1 element to add.

◆ key_eq()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
key_equal etl::iunordered_set< TKey, THash, TKeyEqual >::key_eq ( ) const
inline

Returns the function that compares the keys.

Returns
The function that compares the keys..

◆ load_factor()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
float etl::iunordered_set< TKey, THash, TKeyEqual >::load_factor ( ) const
inline

Returns the load factor = size / bucket_count.

Returns
The load factor = size / bucket_count.

◆ max_bucket_count()

template<typename TKey , typename THash = etl::hash<TKey>, typename TKeyEqual = etl::equal_to<TKey>>
size_type etl::iunordered_set< TKey, THash, TKeyEqual >::max_bucket_count ( ) const
inline

Returns the maximum number of the buckets the container can hold.

Returns
The maximum number of the buckets the container can hold.

Function Documentation

◆ operator!=()

template<typename TKey , typename TMapped , typename TKeyCompare >
bool etl::operator!= ( const etl::iunordered_set< TKey, TMapped, TKeyCompare > &  lhs,
const etl::iunordered_set< TKey, TMapped, TKeyCompare > &  rhs 
)

Not equal operator.

Parameters
lhsReference to the first unordered_set.
rhsReference to the second unordered_set.
Returns
true if the sets are not equal, otherwise false

◆ operator==()

template<typename TKey , typename TMapped , typename TKeyCompare >
bool etl::operator== ( const etl::iunordered_set< TKey, TMapped, TKeyCompare > &  lhs,
const etl::iunordered_set< TKey, TMapped, TKeyCompare > &  rhs 
)

Equal operator.

Parameters
lhsReference to the first unordered_set.
rhsReference to the second unordered_set.
Returns
true if the sets are equal, otherwise false