Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

unordered_set< TKey, MAX_SIZE_, MAX_BUCKETS_, THash, TKeyEqual > Class Template Reference

unordered_set< TKey, MAX_SIZE_, MAX_BUCKETS_, THash, TKeyEqual > Class Template Reference

A templated unordered_set implementation that uses a fixed size buffer. More...

#include <unordered_set.h>

Inherits etl::iunordered_set< TKey, THash, TKeyEqual >.

Public Member Functions

 unordered_set ()
 Default constructor.
 unordered_set (const unordered_set &other)
 Copy constructor.
template<typename TIterator >
 unordered_set (TIterator first_, TIterator last_)
 Constructor, from an iterator range.
 ~unordered_set ()
 Destructor.
unordered_setoperator= (const unordered_set &rhs)
 Assignment operator.
iterator begin ()
 Returns an iterator to the beginning of the unordered_set.
const_iterator begin () const
 Returns a const_iterator to the beginning of the unordered_set.
local_iterator begin (size_t i)
 Returns an iterator to the beginning of the unordered_set bucket.
local_const_iterator begin (size_t i) const
 Returns a const_iterator to the beginning of the unordered_set bucket.
const_iterator cbegin () const
 Returns a const_iterator to the beginning of the unordered_set.
local_const_iterator cbegin (size_t i) const
 Returns a const_iterator to the beginning of the unordered_set bucket.
iterator end ()
 Returns an iterator to the end of the unordered_set.
const_iterator end () const
 Returns a const_iterator to the end of the unordered_set.
local_iterator end (size_t i)
 Returns an iterator to the end of the unordered_set bucket.
local_const_iterator end (size_t i) const
 Returns a const_iterator to the end of the unordered_set bucket.
const_iterator cend () const
 Returns a const_iterator to the end of the unordered_set.
local_const_iterator cend (size_t i) const
 Returns a const_iterator to the end of the unordered_set bucket.
size_type get_bucket_index (key_parameter_t key) const
 Returns the bucket index for the key.
size_type bucket_size (key_parameter_t key) const
 Returns the size of the bucket key.
size_type max_bucket_count () const
 Returns the maximum number of the buckets the container can hold.
size_type bucket_count () const
 Returns the number of the buckets the container holds.
template<typename TIterator >
void assign (TIterator first_, TIterator last_)
 Assigns values to the unordered_set.
std::pair< iterator, bool > insert (const value_type &key)
 Inserts a value to the unordered_set.
iterator insert (const_iterator position, const value_type &key)
 Inserts a value to the unordered_set.
template<class TIterator >
void insert (TIterator first_, TIterator last_)
 Inserts a range of values to the unordered_set.
size_t erase (key_parameter_t key)
 Erases an element.
iterator erase (const_iterator ielement)
 Erases an element.
iterator erase (const_iterator first_, const_iterator last_)
 Erases a range of elements.
void clear ()
 Clears the unordered_set.
size_t count (key_parameter_t key) const
 Counts an element.
iterator find (key_parameter_t key)
 Finds an element.
const_iterator find (key_parameter_t key) const
 Finds an element.
std::pair< iterator, iterator > equal_range (key_parameter_t key)
 Returns a range containing all elements with key 'key' in the container.
std::pair< const_iterator,
const_iterator > 
equal_range (key_parameter_t key) const
 Returns a range containing all elements with key 'key' in the container.
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.
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
 Returns the remaining capacity.
float load_factor () const
 Returns the load factor = size / bucket_count.
hasher hash_function () const
 Returns the function that hashes the keys.
key_equal key_eq () const
 Returns the function that compares the keys.

Protected Member Functions

void initialise ()
 Initialise the unordered_set.

Detailed Description

template<typename TKey, const size_t MAX_SIZE_, size_t MAX_BUCKETS_ = MAX_SIZE_, typename THash = etl::hash<TKey>, typename TKeyEqual = std::equal_to<TKey>>
class etl::unordered_set< TKey, MAX_SIZE_, MAX_BUCKETS_, THash, TKeyEqual >

A templated unordered_set implementation that uses a fixed size buffer.

Definition at line 1199 of file unordered_set.h.


Constructor & Destructor Documentation

Default constructor.

Definition at line 1213 of file unordered_set.h.

unordered_set ( const unordered_set< TKey, MAX_SIZE_, MAX_BUCKETS_, THash, TKeyEqual > &  other )

Copy constructor.

Definition at line 1222 of file unordered_set.h.

unordered_set ( TIterator  first_,
TIterator  last_ 
)

Constructor, from an iterator range.

Template Parameters:
TIteratorThe iterator type.
Parameters:
firstThe iterator to the first element.
lastThe iterator to the last element + 1.

Definition at line 1235 of file unordered_set.h.

~unordered_set (  )

Destructor.

Definition at line 1244 of file unordered_set.h.


Member Function Documentation

void assign ( TIterator  first_,
TIterator  last_ 
) [inherited]

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.

Definition at line 633 of file unordered_set.h.

size_t available (  ) const [inherited]

Returns the remaining capacity.

Returns:
The remaining capacity.

Definition at line 1030 of file unordered_set.h.

iterator begin (  ) [inherited]

Returns an iterator to the beginning of the unordered_set.

Returns:
An iterator to the beginning of the unordered_set.

Definition at line 483 of file unordered_set.h.

local_iterator begin ( size_t  i ) [inherited]

Returns an iterator to the beginning of the unordered_set bucket.

Returns:
An iterator to the beginning of the unordered_set bucket.

Definition at line 510 of file unordered_set.h.

local_const_iterator begin ( size_t  i ) const [inherited]

Returns a const_iterator to the beginning of the unordered_set bucket.

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

Definition at line 519 of file unordered_set.h.

const_iterator begin (  ) const [inherited]

Returns a const_iterator to the beginning of the unordered_set.

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

Definition at line 492 of file unordered_set.h.

size_type bucket_count (  ) const [inherited]

Returns the number of the buckets the container holds.

Returns:
The number of the buckets the container holds.

Definition at line 620 of file unordered_set.h.

size_type bucket_size ( key_parameter_t  key ) const [inherited]

Returns the size of the bucket key.

Returns:
The bucket size of the bucket key.

Definition at line 600 of file unordered_set.h.

const_iterator cbegin (  ) const [inherited]

Returns a const_iterator to the beginning of the unordered_set.

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

Definition at line 501 of file unordered_set.h.

local_const_iterator cbegin ( size_t  i ) const [inherited]

Returns a const_iterator to the beginning of the unordered_set bucket.

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

Definition at line 528 of file unordered_set.h.

const_iterator cend (  ) const [inherited]

Returns a const_iterator to the end of the unordered_set.

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

Definition at line 555 of file unordered_set.h.

local_const_iterator cend ( size_t  i ) const [inherited]

Returns a const_iterator to the end of the unordered_set bucket.

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

Definition at line 582 of file unordered_set.h.

void clear (  ) [inherited]

Clears the unordered_set.

Definition at line 869 of file unordered_set.h.

size_t count ( key_parameter_t  key ) const [inherited]

Counts an element.

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

Definition at line 879 of file unordered_set.h.

bool empty (  ) const [inherited]

Checks to see if the unordered_set is empty.

Definition at line 1013 of file unordered_set.h.

iterator end (  ) [inherited]

Returns an iterator to the end of the unordered_set.

Returns:
An iterator to the end of the unordered_set.

Definition at line 537 of file unordered_set.h.

const_iterator end (  ) const [inherited]

Returns a const_iterator to the end of the unordered_set.

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

Definition at line 546 of file unordered_set.h.

local_iterator end ( size_t  i ) [inherited]

Returns an iterator to the end of the unordered_set bucket.

Returns:
An iterator to the end of the unordered_set bucket.

Definition at line 564 of file unordered_set.h.

local_const_iterator end ( size_t  i ) const [inherited]

Returns a const_iterator to the end of the unordered_set bucket.

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

Definition at line 573 of file unordered_set.h.

std::pair<iterator, iterator> equal_range ( key_parameter_t  key ) [inherited]

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().

Definition at line 960 of file unordered_set.h.

std::pair<const_iterator, const_iterator> equal_range ( key_parameter_t  key ) const [inherited]

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().

Definition at line 981 of file unordered_set.h.

iterator erase ( const_iterator  ielement ) [inherited]

Erases an element.

Parameters:
ielementIterator to the element.

Definition at line 787 of file unordered_set.h.

size_t erase ( key_parameter_t  key ) [inherited]

Erases an element.

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

Definition at line 753 of file unordered_set.h.

iterator erase ( const_iterator  first_,
const_iterator  last_ 
) [inherited]

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.

Definition at line 818 of file unordered_set.h.

iterator find ( key_parameter_t  key ) [inherited]

Finds an element.

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

Definition at line 889 of file unordered_set.h.

const_iterator find ( key_parameter_t  key ) const [inherited]

Finds an element.

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

Definition at line 923 of file unordered_set.h.

bool full (  ) const [inherited]

Checks to see if the unordered_set is full.

Definition at line 1021 of file unordered_set.h.

size_type get_bucket_index ( key_parameter_t  key ) const [inherited]

Returns the bucket index for the key.

Returns:
The bucket index for the key.

Definition at line 591 of file unordered_set.h.

hasher hash_function (  ) const [inherited]

Returns the function that hashes the keys.

Returns:
The function that hashes the keys..

Definition at line 1048 of file unordered_set.h.

void initialise (  ) [protected, inherited]

Initialise the unordered_set.

Definition at line 1091 of file unordered_set.h.

std::pair<iterator, bool> insert ( const value_type &  key ) [inherited]

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.

Definition at line 654 of file unordered_set.h.

iterator insert ( const_iterator  position,
const value_type &  key 
) [inherited]

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.

Definition at line 727 of file unordered_set.h.

void insert ( TIterator  first_,
TIterator  last_ 
) [inherited]

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.

Definition at line 740 of file unordered_set.h.

key_equal key_eq (  ) const [inherited]

Returns the function that compares the keys.

Returns:
The function that compares the keys..

Definition at line 1057 of file unordered_set.h.

float load_factor (  ) const [inherited]

Returns the load factor = size / bucket_count.

Returns:
The load factor = size / bucket_count.

Definition at line 1039 of file unordered_set.h.

size_type max_bucket_count (  ) const [inherited]

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

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

Definition at line 611 of file unordered_set.h.

size_type max_size (  ) const [inherited]

Gets the maximum possible size of the unordered_set.

Definition at line 1005 of file unordered_set.h.

unordered_set& operator= ( const unordered_set< TKey, MAX_SIZE_, MAX_BUCKETS_, THash, TKeyEqual > &  rhs )

Assignment operator.

Definition at line 1252 of file unordered_set.h.

size_type size (  ) const [inherited]

Gets the size of the unordered_set.

Definition at line 997 of file unordered_set.h.