Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

flat_map< TKey, TValue, MAX_SIZE_, TCompare > Class Template Reference

flat_map< TKey, TValue, MAX_SIZE_, TCompare > Class Template Reference
[flat_map]

A flat_map implementation that uses a fixed size buffer. More...

#include <flat_map.h>

Inherits iflat_map< TKey, TValue, TCompare >.

Public Member Functions

 flat_map ()
 Constructor.
 flat_map (const flat_map &other)
 Copy constructor.
template<typename TIterator >
 flat_map (TIterator first, TIterator last)
 Constructor, from an iterator range.
 ~flat_map ()
 Destructor.
flat_mapoperator= (const flat_map &rhs)
 Assignment operator.
iterator begin ()
 Returns an iterator to the beginning of the flat_map.
const_iterator begin () const
 Returns a const_iterator to the beginning of the flat_map.
iterator end ()
 Returns an iterator to the end of the flat_map.
const_iterator end () const
 Returns a const_iterator to the end of the flat_map.
const_iterator cbegin () const
 Returns a const_iterator to the beginning of the flat_map.
const_iterator cend () const
 Returns a const_iterator to the end of the flat_map.
reverse_iterator rbegin ()
 Returns an reverse iterator to the reverse beginning of the flat_map.
const_reverse_iterator rbegin () const
 Returns a const reverse iterator to the reverse beginning of the flat_map.
reverse_iterator rend ()
 Returns a reverse iterator to the end + 1 of the flat_map.
const_reverse_iterator rend () const
 Returns a const reverse iterator to the end + 1 of the flat_map.
const_reverse_iterator crbegin () const
 Returns a const reverse iterator to the reverse beginning of the flat_map.
const_reverse_iterator crend () const
 Returns a const reverse iterator to the end + 1 of the flat_map.
mapped_type & operator[] (key_parameter_t key)
 Returns a reference to the value at index 'key'.
mapped_type & at (key_parameter_t key)
 Returns a reference to the value at index 'key' If asserts or exceptions are enabled, emits an etl::flat_map_out_of_bounds if the key is not in the range.
const mapped_type & at (key_parameter_t key) const
 Returns a const reference to the value at index 'key' If asserts or exceptions are enabled, emits an etl::flat_map_out_of_bounds if the key is not in the range.
void assign (TIterator first, TIterator last)
 Assigns values to the flat_map.
std::pair< iterator, bool > insert (const_reference value)
 Inserts a value to the flat_map.
iterator insert (iterator position, const_reference value)
 Inserts a value to the flat_map.
void insert (TIterator first, TIterator last)
 Inserts a range of values to the flat_map.
size_t erase (key_parameter_t key)
 Erases an element.
void erase (iterator i_element)
 Erases an element.
void erase (iterator first, iterator last)
 Erases a range of elements.
void clear ()
 Clears the flat_map.
iterator find (key_parameter_t key)
 Finds an element.
const_iterator find (key_parameter_t key) const
 Finds an element.
size_t count (key_parameter_t key) const
 Counts an element.
iterator lower_bound (key_parameter_t key)
 Finds the lower bound of a key.
const_iterator lower_bound (key_parameter_t key) const
 Finds the lower bound of a key.
iterator upper_bound (key_parameter_t key)
 Finds the upper bound of a key.
const_iterator upper_bound (key_parameter_t key) const
 Finds the upper bound of a key.
std::pair< iterator, iterator > equal_range (key_parameter_t key)
 Finds the range of equal elements of a key.
std::pair< const_iterator,
const_iterator > 
equal_range (key_parameter_t key) const
 Finds the range of equal elements of a key.
size_type size () const
 Gets the current size of the flat_map.
bool empty () const
 Checks the 'empty' state of the flat_map.
bool full () const
 Checks the 'full' state of the flat_map.
size_type capacity () const
 Returns the capacity of the flat_map.
size_type max_size () const
 Returns the maximum possible size of the flat_map.
size_t available () const
 Returns the remaining capacity.

Detailed Description

template<typename TKey, typename TValue, const size_t MAX_SIZE_, typename TCompare = std::less<TKey>>
class etl::flat_map< TKey, TValue, MAX_SIZE_, TCompare >

A flat_map implementation that uses a fixed size buffer.

Template Parameters:
TKeyThe key type.
TValueThe value type.
TCompareThe type to compare keys. Default = std::less<TKey>
MAX_SIZE_The maximum number of elements that can be stored.

Definition at line 618 of file flat_map.h.


Constructor & Destructor Documentation

flat_map (  )

Constructor.

Definition at line 627 of file flat_map.h.

flat_map ( const flat_map< TKey, TValue, MAX_SIZE_, TCompare > &  other )

Copy constructor.

Definition at line 635 of file flat_map.h.

flat_map ( 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 648 of file flat_map.h.

~flat_map (  )

Destructor.

Definition at line 657 of file flat_map.h.


Member Function Documentation

void assign ( TIterator  first,
TIterator  last 
) [inherited]

Assigns values to the flat_map.

If ETL_THROW_EXCEPTIONS & ETL_DEBUG are defined, emits flat_map_full if the flat_map does not have enough free space. If ETL_THROW_EXCEPTIONS & ETL_DEBUG are defined, emits flat_map_iterator if the iterators are reversed.

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

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 272 of file flat_map.h.

mapped_type& at ( key_parameter_t  key ) [inherited]

Returns a reference to the value at index 'key' If asserts or exceptions are enabled, emits an etl::flat_map_out_of_bounds if the key is not in the range.

Parameters:
iThe index.
Returns:
A reference to the value at index 'key'

Definition at line 248 of file flat_map.h.

const mapped_type& at ( key_parameter_t  key ) const [inherited]

Returns a const reference to the value at index 'key' If asserts or exceptions are enabled, emits an etl::flat_map_out_of_bounds if the key is not in the range.

Parameters:
iThe index.
Returns:
A const reference to the value at index 'key'

Definition at line 259 of file flat_map.h.

size_t available (  ) const [inherited]

Returns the remaining capacity.

Returns:
The remaining capacity.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 556 of file flat_map.h.

iterator begin (  ) [inherited]

Returns an iterator to the beginning of the flat_map.

Returns:
An iterator to the beginning of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 115 of file flat_map.h.

const_iterator begin (  ) const [inherited]

Returns a const_iterator to the beginning of the flat_map.

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

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 124 of file flat_map.h.

size_type capacity (  ) const [inherited]

Returns the capacity of the flat_map.

Returns:
The capacity of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 538 of file flat_map.h.

const_iterator cbegin (  ) const [inherited]

Returns a const_iterator to the beginning of the flat_map.

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

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 151 of file flat_map.h.

const_iterator cend (  ) const [inherited]

Returns a const_iterator to the end of the flat_map.

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

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 160 of file flat_map.h.

void clear (  ) [inherited]

Clears the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 399 of file flat_map.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 429 of file flat_map.h.

const_reverse_iterator crbegin (  ) const [inherited]

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

Returns:
Const reverse iterator to the reverse beginning of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 205 of file flat_map.h.

const_reverse_iterator crend (  ) const [inherited]

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

Returns:
Const reverse iterator to the end + 1 of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 214 of file flat_map.h.

bool empty (  ) const [inherited]

Checks the 'empty' state of the flat_map.

Returns:
true if empty.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 520 of file flat_map.h.

iterator end (  ) [inherited]

Returns an iterator to the end of the flat_map.

Returns:
An iterator to the end of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 133 of file flat_map.h.

const_iterator end (  ) const [inherited]

Returns a const_iterator to the end of the flat_map.

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

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 142 of file flat_map.h.

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

Finds the range of equal elements of a key.

Parameters:
keyThe key to search for.
Returns:
An iterator pair.

Definition at line 479 of file flat_map.h.

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

Finds the range of equal elements of a key.

Parameters:
keyThe key to search for.
Returns:
An iterator pair.

Definition at line 489 of file flat_map.h.

void erase ( iterator  first,
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 by last.

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

Definition at line 381 of file flat_map.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 344 of file flat_map.h.

void erase ( iterator  i_element ) [inherited]

Erases an element.

Parameters:
i_elementIterator to the element.

Definition at line 366 of file flat_map.h.

iterator find ( key_parameter_t  key ) [inherited]

Finds an element.

Parameters:
keyThe key to search for.
Returns:
An iterator pointing to the element or end() if not found.

Definition at line 409 of file flat_map.h.

const_iterator find ( key_parameter_t  key ) const [inherited]

Finds an element.

Parameters:
keyThe key to search for.
Returns:
An iterator pointing to the element or end() if not found.

Definition at line 419 of file flat_map.h.

bool full (  ) const [inherited]

Checks the 'full' state of the flat_map.

Returns:
true if full.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 529 of file flat_map.h.

std::pair<iterator, bool> insert ( const_reference  value ) [inherited]

Inserts a value to the flat_map.

If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full.

Parameters:
valueThe value to insert.

Definition at line 292 of file flat_map.h.

iterator insert ( iterator  position,
const_reference  value 
) [inherited]

Inserts a value to the flat_map.

If asserts or exceptions are enabled, emits flat_map_full if the flat_map is already full.

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

Definition at line 318 of file flat_map.h.

void insert ( TIterator  first,
TIterator  last 
) [inherited]

Inserts a range of values to the flat_map.

If asserts or exceptions are enabled, emits flat_map_full if the flat_map does not have enough free space.

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

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 331 of file flat_map.h.

iterator lower_bound ( key_parameter_t  key ) [inherited]

Finds the lower bound of a key.

Parameters:
keyThe key to search for.
Returns:
An iterator.

Definition at line 439 of file flat_map.h.

const_iterator lower_bound ( key_parameter_t  key ) const [inherited]

Finds the lower bound of a key.

Parameters:
keyThe key to search for.
Returns:
An iterator.

Definition at line 449 of file flat_map.h.

size_type max_size (  ) const [inherited]

Returns the maximum possible size of the flat_map.

Returns:
The maximum size of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 547 of file flat_map.h.

flat_map& operator= ( const flat_map< TKey, TValue, MAX_SIZE_, TCompare > &  rhs )

Assignment operator.

Definition at line 665 of file flat_map.h.

mapped_type& operator[] ( key_parameter_t  key ) [inherited]

Returns a reference to the value at index 'key'.

Parameters:
iThe index.
Returns:
A reference to the value at index 'key'

Definition at line 224 of file flat_map.h.

reverse_iterator rbegin (  ) [inherited]

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

Returns:
Iterator to the reverse beginning of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 169 of file flat_map.h.

const_reverse_iterator rbegin (  ) const [inherited]

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

Returns:
Const iterator to the reverse beginning of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 178 of file flat_map.h.

const_reverse_iterator rend (  ) const [inherited]

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

Returns:
Const reverse iterator to the end + 1 of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 196 of file flat_map.h.

reverse_iterator rend (  ) [inherited]

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

Returns:
Reverse iterator to the end + 1 of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 187 of file flat_map.h.

size_type size (  ) const [inherited]

Gets the current size of the flat_map.

Returns:
The current size of the flat_map.

Reimplemented from ireference_flat_map< TKey, TValue, TCompare >.

Definition at line 511 of file flat_map.h.

iterator upper_bound ( key_parameter_t  key ) [inherited]

Finds the upper bound of a key.

Parameters:
keyThe key to search for.
Returns:
An iterator.

Definition at line 459 of file flat_map.h.

const_iterator upper_bound ( key_parameter_t  key ) const [inherited]

Finds the upper bound of a key.

Parameters:
keyThe key to search for.
Returns:
An iterator.

Definition at line 469 of file flat_map.h.