Loading...
Searching...
No Matches
flat_set

## Classes

class | etl::iflat_set< T, TKeyCompare >
class | etl::flat_set< T, MAX_SIZE_, TCompare >

## Functions

template<typename T, typename TKeyCompare>
bool | etl::operator== (const etl::iflat_set< T, TKeyCompare > &lhs, const etl::iflat_set< T, TKeyCompare > &rhs)
template<typename T, typename TKeyCompare>
bool | etl::operator!= (const etl::iflat_set< T, TKeyCompare > &lhs, const etl::iflat_set< T, TKeyCompare > &rhs)

## Detailed Description

A flat_set with the capacity defined at compile time. Has insertion of O(N) and find of O(logN) Duplicate entries and not allowed.

## Class Documentation

## etl::iflat_set

class etl::iflat_set

template<typename T, typename TKeyCompare = etl::less<T>>
class etl::iflat_set< T, TKeyCompare >

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

### Public Types

typedef T | key_type
typedef T | value_type
typedef TKeyCompare | key_compare
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 refset_t::iterator | iterator
typedef refset_t::const_iterator | const_iterator
typedef ETL_OR_STD::reverse_iterator< iterator > | reverse_iterator
typedef ETL_OR_STD::reverse_iterator< const_iterator > | const_reverse_iterator
typedef etl::iterator_traits< iterator >::difference_type | difference_type

### Public Member Functions

iterator | begin ()
const_iterator | begin () const
iterator | end ()
const_iterator | end () const
const_iterator | cbegin () const
const_iterator | cend () const
reverse_iterator | rbegin ()
const_reverse_iterator | rbegin () const
reverse_iterator | rend ()
const_reverse_iterator | rend () const
const_reverse_iterator | crbegin () const
const_reverse_iterator | crend () const
template<typename TIterator>
void | assign (TIterator first, TIterator last)
ETL_OR_STD::pair< iterator, bool > | insert (const_reference value)
iterator | insert (const_iterator, const_reference value)
template<class TIterator>
void | insert (TIterator first, TIterator last)
ETL_OR_STD::pair< iterator, bool > | emplace (const_reference value)
| Emplaces a value to the set.
ETL_OR_STD::pair< iterator, bool > | emplace ()
| Emplaces a value to the set.
template<typename T1>
ETL_OR_STD::pair< iterator, bool > | emplace (const T1 &value1)
| Emplaces a value to the set.
template<typename T1, typename T2>
ETL_OR_STD::pair< iterator, bool > | emplace (const T1 &value1, const T2 &value2)
| Emplaces a value to the set.
template<typename T1, typename T2, typename T3>
ETL_OR_STD::pair< iterator, bool > | emplace (const T1 &value1, const T2 &value2, const T3 &value3)
| Emplaces a value to the set.
template<typename T1, typename T2, typename T3, typename T4>
ETL_OR_STD::pair< iterator, bool > | emplace (const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
| Emplaces a value to the set.
size_t | erase (key_parameter_t key)
iterator | erase (iterator i_element)
iterator | erase (const_iterator i_element)
iterator | erase (const_iterator first, const_iterator last)
void | clear ()
| Clears the flat_set.
iterator | find (key_parameter_t key)
const_iterator | find (key_parameter_t key) const
size_t | count (key_parameter_t key) const
iterator | lower_bound (key_parameter_t key)
const_iterator | lower_bound (key_parameter_t key) const
iterator | upper_bound (key_parameter_t key)
const_iterator | upper_bound (key_parameter_t key) const
ETL_OR_STD::pair< iterator, iterator > | equal_range (key_parameter_t key)
ETL_OR_STD::pair< const_iterator, const_iterator > | equal_range (key_parameter_t key) const
bool | contains (key_parameter_t key) const
| Check if the map contains the key.
iflat_set & | operator= (const iflat_set &rhs)
| Assignment operator.
size_type | size () const
bool | empty () const
bool | full () const
size_type | capacity () const
size_type | max_size () const
size_t | available () const

### Protected Member Functions

| iflat_set (lookup_t &lookup_, storage_t &storage_)
| Constructor.
| ~iflat_set ()
| Destructor.

#### Member Function Documentation

## assign()

template<typename T, typename TKeyCompare = etl::less<T>>
template<typename TIterator>

void etl::iflat_set< T, TKeyCompare >::assign | ( | TIterator | first,
|  | TIterator | last )

inline

Assigns values to the flat_set. If asserts or exceptions are enabled, emits flat_set_full if the flat_set does not have enough free space. If asserts or exceptions are enabled, emits flat_set_iterator if the iterators are reversed.

Parameters

  first | The iterator to the first element.
  last | The iterator to the last element + 1.

## available()

template<typename T, typename TKeyCompare = etl::less<T>>

size_t etl::iflat_set< T, TKeyCompare >::available | ( |  | ) | const

inline

Returns the remaining capacity.

Returns
  The remaining capacity.

## begin() [1/2]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::begin | ( |  | ) |

inline

Returns an iterator to the beginning of the flat_set.

Returns
  An iterator to the beginning of the flat_set.

## begin() [2/2]

template<typename T, typename TKeyCompare = etl::less<T>>

const_iterator etl::iflat_set< T, TKeyCompare >::begin | ( |  | ) | const

inline

Returns a const_iterator to the beginning of the flat_set.

Returns
  A const iterator to the beginning of the flat_set.

## capacity()

template<typename T, typename TKeyCompare = etl::less<T>>

size_type etl::iflat_set< T, TKeyCompare >::capacity | ( |  | ) | const

inline

Returns the capacity of the flat_set.

Returns
  The capacity of the flat_set.

## cbegin()

template<typename T, typename TKeyCompare = etl::less<T>>

const_iterator etl::iflat_set< T, TKeyCompare >::cbegin | ( |  | ) | const

inline

Returns a const_iterator to the beginning of the flat_set.

Returns
  A const iterator to the beginning of the flat_set.

## cend()

template<typename T, typename TKeyCompare = etl::less<T>>

const_iterator etl::iflat_set< T, TKeyCompare >::cend | ( |  | ) | const

inline

Returns a const_iterator to the end of the flat_set.

Returns
  A const iterator to the end of the flat_set.

## count()

template<typename T, typename TKeyCompare = etl::less<T>>

size_t etl::iflat_set< T, TKeyCompare >::count | ( | key_parameter_t | key | ) | const

inline

Counts an element.

Parameters

  key | The key to search for.

Returns
  1 if the key exists, otherwise 0.

## crbegin()

template<typename T, typename TKeyCompare = etl::less<T>>

const_reverse_iterator etl::iflat_set< T, TKeyCompare >::crbegin | ( |  | ) | const

inline

Returns a const reverse iterator to the reverse beginning of the flat_set.

Returns
  Const reverse iterator to the reverse beginning of the flat_set.

## crend()

template<typename T, typename TKeyCompare = etl::less<T>>

const_reverse_iterator etl::iflat_set< T, TKeyCompare >::crend | ( |  | ) | const

inline

Returns a const reverse iterator to the end + 1 of the flat_set.

Returns
  Const reverse iterator to the end + 1 of the flat_set.

## emplace()

template<typename T, typename TKeyCompare = etl::less<T>>

ETL_OR_STD::pair< iterator, bool > etl::iflat_set< T, TKeyCompare >::emplace | ( |  | ) |

inline

Emplaces a value to the set.

Emplaces a value to the set.

## empty()

template<typename T, typename TKeyCompare = etl::less<T>>

bool etl::iflat_set< T, TKeyCompare >::empty | ( |  | ) | const

inline

Checks the 'empty' state of the flat_set.

Returns
  true if empty.

## end() [1/2]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::end | ( |  | ) |

inline

Returns an iterator to the end of the flat_set.

Returns
  An iterator to the end of the flat_set.

## end() [2/2]

template<typename T, typename TKeyCompare = etl::less<T>>

const_iterator etl::iflat_set< T, TKeyCompare >::end | ( |  | ) | const

inline

Returns a const_iterator to the end of the flat_set.

Returns
  A const iterator to the end of the flat_set.

## equal_range() [1/2]

template<typename T, typename TKeyCompare = etl::less<T>>

ETL_OR_STD::pair< iterator, iterator > etl::iflat_set< T, TKeyCompare >::equal_range | ( | key_parameter_t | key | ) |

inline

Finds the range of equal elements of a key

Parameters

  key | The key to search for.

Returns
  An iterator pair.

## equal_range() [2/2]

template<typename T, typename TKeyCompare = etl::less<T>>

ETL_OR_STD::pair< const_iterator, const_iterator > etl::iflat_set< T, TKeyCompare >::equal_range | ( | key_parameter_t | key | ) | const

inline

Finds the range of equal elements of a key

Parameters

  key | The key to search for.

Returns
  An iterator pair.

## erase() [1/4]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::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 by last.

Parameters

  first | Iterator to the first element.
  last | Iterator to the last element.

## erase() [2/4]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::erase | ( | const_iterator | i_element | ) |

inline

Erases an element.

Parameters

  i_element | Iterator to the element.

## erase() [3/4]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::erase | ( | iterator | i_element | ) |

inline

Erases an element.

Parameters

  i_element | Iterator to the element.

## erase() [4/4]

template<typename T, typename TKeyCompare = etl::less<T>>

size_t etl::iflat_set< T, TKeyCompare >::erase | ( | key_parameter_t | key | ) |

inline

Erases an element.

Parameters

  key | The key to erase.

Returns
  The number of elements erased. 0 or 1.

## find() [1/2]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::find | ( | key_parameter_t | key | ) |

inline

Finds an element.

Parameters

  key | The key to search for.

Returns
  An iterator pointing to the element or end() if not found.

## find() [2/2]

template<typename T, typename TKeyCompare = etl::less<T>>

const_iterator etl::iflat_set< T, TKeyCompare >::find | ( | key_parameter_t | key | ) | const

inline

Finds an element.

Parameters

  key | The key to search for.

Returns
  An iterator pointing to the element or end() if not found.

## full()

template<typename T, typename TKeyCompare = etl::less<T>>

bool etl::iflat_set< T, TKeyCompare >::full | ( |  | ) | const

inline

Checks the 'full' state of the flat_set.

Returns
  true if full.

## insert() [1/3]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::insert | ( | const_iterator | ,
|  | const_reference | value )

inline

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

Parameters

  position | The position to insert at.
  value | The value to insert.

## insert() [2/3]

template<typename T, typename TKeyCompare = etl::less<T>>

ETL_OR_STD::pair< iterator, bool > etl::iflat_set< T, TKeyCompare >::insert | ( | const_reference | value | ) |

inline

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

Parameters

  value | The value to insert.

## insert() [3/3]

template<typename T, typename TKeyCompare = etl::less<T>>
template<class TIterator>

void etl::iflat_set< T, TKeyCompare >::insert | ( | TIterator | first,
|  | TIterator | last )

inline

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

Parameters

  position | The position to insert at.
  first | The first element to add.
  last | The last + 1 element to add.

## lower_bound() [1/2]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::lower_bound | ( | key_parameter_t | key | ) |

inline

Finds the lower bound of a key

Parameters

  key | The key to search for.

Returns
  An iterator.

## lower_bound() [2/2]

template<typename T, typename TKeyCompare = etl::less<T>>

const_iterator etl::iflat_set< T, TKeyCompare >::lower_bound | ( | key_parameter_t | key | ) | const

inline

Finds the lower bound of a key

Parameters

  key | The key to search for.

Returns
  An iterator.

## max_size()

template<typename T, typename TKeyCompare = etl::less<T>>

size_type etl::iflat_set< T, TKeyCompare >::max_size | ( |  | ) | const

inline

Returns the maximum possible size of the flat_set.

Returns
  The maximum size of the flat_set.

## rbegin() [1/2]

template<typename T, typename TKeyCompare = etl::less<T>>

reverse_iterator etl::iflat_set< T, TKeyCompare >::rbegin | ( |  | ) |

inline

Returns an reverse iterator to the reverse beginning of the flat_set.

Returns
  Iterator to the reverse beginning of the flat_set.

## rbegin() [2/2]

template<typename T, typename TKeyCompare = etl::less<T>>

const_reverse_iterator etl::iflat_set< T, TKeyCompare >::rbegin | ( |  | ) | const

inline

Returns a const reverse iterator to the reverse beginning of the flat_set.

Returns
  Const iterator to the reverse beginning of the flat_set.

## rend() [1/2]

template<typename T, typename TKeyCompare = etl::less<T>>

reverse_iterator etl::iflat_set< T, TKeyCompare >::rend | ( |  | ) |

inline

Returns a reverse iterator to the end + 1 of the flat_set.

Returns
  Reverse iterator to the end + 1 of the flat_set.

## rend() [2/2]

template<typename T, typename TKeyCompare = etl::less<T>>

const_reverse_iterator etl::iflat_set< T, TKeyCompare >::rend | ( |  | ) | const

inline

Returns a const reverse iterator to the end + 1 of the flat_set.

Returns
  Const reverse iterator to the end + 1 of the flat_set.

## size()

template<typename T, typename TKeyCompare = etl::less<T>>

size_type etl::iflat_set< T, TKeyCompare >::size | ( |  | ) | const

inline

Gets the current size of the flat_set.

Returns
  The current size of the flat_set.

## upper_bound() [1/2]

template<typename T, typename TKeyCompare = etl::less<T>>

iterator etl::iflat_set< T, TKeyCompare >::upper_bound | ( | key_parameter_t | key | ) |

inline

Finds the upper bound of a key

Parameters

  key | The key to search for.

Returns
  An iterator.

## upper_bound() [2/2]

template<typename T, typename TKeyCompare = etl::less<T>>

const_iterator etl::iflat_set< T, TKeyCompare >::upper_bound | ( | key_parameter_t | key | ) | const

inline

Finds the upper bound of a key

Parameters

  key | The key to search for.

Returns
  An iterator.

## etl::flat_set

class etl::flat_set

template<typename T, const size_t MAX_SIZE_, typename TCompare = etl::less<T>>
class etl::flat_set< T, MAX_SIZE_, TCompare >

A flat_set implementation that uses a fixed size buffer.

Template Parameters

  T | The value type.
  TCompare | The type to compare keys. Default = etl::less<T>
  MAX_SIZE_ | The maximum number of elements that can be stored.

### Public Member Functions

| flat_set ()
| Constructor.
| flat_set (const flat_set &other)
| Copy constructor.
template<typename TIterator>
| flat_set (TIterator first, TIterator last)
| ~flat_set ()
| Destructor.
flat_set & | operator= (const flat_set &rhs)
| Assignment operator.
Public Member Functions inherited from etl::iflat_set< T, TKeyCompare >
iterator | begin ()
const_iterator | begin () const
iterator | end ()
const_iterator | end () const
const_iterator | cbegin () const
const_iterator | cend () const
reverse_iterator | rbegin ()
const_reverse_iterator | rbegin () const
reverse_iterator | rend ()
const_reverse_iterator | rend () const
const_reverse_iterator | crbegin () const
const_reverse_iterator | crend () const
template<typename TIterator>
void | assign (TIterator first, TIterator last)
ETL_OR_STD::pair< iterator, bool > | insert (const_reference value)
iterator | insert (const_iterator, const_reference value)
template<class TIterator>
void | insert (TIterator first, TIterator last)
ETL_OR_STD::pair< iterator, bool > | emplace (const_reference value)
| Emplaces a value to the set.
ETL_OR_STD::pair< iterator, bool > | emplace ()
| Emplaces a value to the set.
template<typename T1>
ETL_OR_STD::pair< iterator, bool > | emplace (const T1 &value1)
| Emplaces a value to the set.
template<typename T1, typename T2>
ETL_OR_STD::pair< iterator, bool > | emplace (const T1 &value1, const T2 &value2)
| Emplaces a value to the set.
template<typename T1, typename T2, typename T3>
ETL_OR_STD::pair< iterator, bool > | emplace (const T1 &value1, const T2 &value2, const T3 &value3)
| Emplaces a value to the set.
template<typename T1, typename T2, typename T3, typename T4>
ETL_OR_STD::pair< iterator, bool > | emplace (const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
| Emplaces a value to the set.
size_t | erase (key_parameter_t key)
iterator | erase (iterator i_element)
iterator | erase (const_iterator i_element)
iterator | erase (const_iterator first, const_iterator last)
void | clear ()
| Clears the flat_set.
iterator | find (key_parameter_t key)
const_iterator | find (key_parameter_t key) const
size_t | count (key_parameter_t key) const
iterator | lower_bound (key_parameter_t key)
const_iterator | lower_bound (key_parameter_t key) const
iterator | upper_bound (key_parameter_t key)
const_iterator | upper_bound (key_parameter_t key) const
ETL_OR_STD::pair< iterator, iterator > | equal_range (key_parameter_t key)
ETL_OR_STD::pair< const_iterator, const_iterator > | equal_range (key_parameter_t key) const
bool | contains (key_parameter_t key) const
| Check if the map contains the key.
iflat_set & | operator= (const iflat_set &rhs)
| Assignment operator.
size_type | size () const
bool | empty () const
bool | full () const
size_type | capacity () const
size_type | max_size () const
size_t | available () const

### Static Public Attributes

static ETL_CONSTANT size_t | MAX_SIZE = MAX_SIZE_

## Additional Inherited Members

Public Types inherited from etl::iflat_set< T, TKeyCompare >
typedef T | key_type
typedef T | value_type
typedef TKeyCompare | key_compare
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 refset_t::iterator | iterator
typedef refset_t::const_iterator | const_iterator
typedef ETL_OR_STD::reverse_iterator< iterator > | reverse_iterator
typedef ETL_OR_STD::reverse_iterator< const_iterator > | const_reverse_iterator
typedef etl::iterator_traits< iterator >::difference_type | difference_type
Protected Member Functions inherited from etl::iflat_set< T, TKeyCompare >
| iflat_set (lookup_t &lookup_, storage_t &storage_)
| Constructor.
| ~iflat_set ()
| Destructor.

#### Constructor & Destructor Documentation

## flat_set()

template<typename T, const size_t MAX_SIZE_, typename TCompare = etl::less<T>>
template<typename TIterator>

etl::flat_set< T, MAX_SIZE_, TCompare >::flat_set | ( | TIterator | first,
|  | TIterator | last )

inline

Constructor, from an iterator range.

Template Parameters

  TIterator | The iterator type.

Parameters

  first | The iterator to the first element.
  last | The iterator to the last element + 1.

## Function Documentation

## operator!=()

template<typename T, typename TKeyCompare>

bool etl::operator!= | ( | const etl::iflat_set< T, TKeyCompare > & | lhs,
|  | const etl::iflat_set< T, TKeyCompare > & | rhs )

Not equal operator.

Parameters

  lhs | Reference to the first flat_set.
  rhs | Reference to the second flat_set.

Returns
  true if the arrays are not equal, otherwise false

## operator==()

template<typename T, typename TKeyCompare>

bool etl::operator== | ( | const etl::iflat_set< T, TKeyCompare > & | lhs,
|  | const etl::iflat_set< T, TKeyCompare > & | rhs )

Equal operator.

Parameters

  lhs | Reference to the first flat_set.
  rhs | Reference to the second flat_set.

Returns
  true if the arrays are equal, otherwise false