Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

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

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

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

#include <map.h>

Inherits imap< TKey, TValue, TCompare >.

Public Types

typedef size_t size_type
 The type used for determining the size of map.

Public Member Functions

 map ()
 Default constructor.
 map (const map &other)
 Copy constructor.
template<typename TIterator >
 map (TIterator first, TIterator last)
 Constructor, from an iterator range.
 ~map ()
 Destructor.
mapoperator= (const map &rhs)
 Assignment operator.
iterator begin ()
 Gets the beginning of the map.
const_iterator begin () const
 Gets the beginning of the map.
iterator end ()
 Gets the end of the map.
const_iterator end () const
 Gets the end of the map.
const_iterator cbegin () const
 Gets the beginning of the map.
const_iterator cend () const
 Gets the end of the map.
reverse_iterator rbegin ()
 Gets the reverse beginning of the list.
const_reverse_iterator rbegin () const
 Gets the reverse beginning of the list.
reverse_iterator rend ()
 Gets the reverse end of the list.
const_reverse_iterator rend () const
 Gets the reverse end of the list.
const_reverse_iterator crbegin () const
 Gets the reverse beginning of the list.
const_reverse_iterator crend () const
 Gets the reverse end of the list.
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::lookup_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::lookup_out_of_bounds if the key is not in the range.
void assign (TIterator first, TIterator last)
 Assigns values to the map.
void clear ()
 Clears the map.
size_type count (key_parameter_t key) const
 Counts the number of elements that contain the key specified.
std::pair< iterator, iterator > equal_range (key_parameter_t key)
 Returns two iterators with bounding (lower bound, upper bound) the key provided.
std::pair< const_iterator,
const_iterator > 
equal_range (key_parameter_t key) const
 Returns two const iterators with bounding (lower bound, upper bound) the key provided.
void erase (iterator position)
 Erases the value at the specified position.
iterator erase (const_iterator position)
 Erases the value at the specified position.
iterator erase (iterator first, iterator last)
 Erases a range of elements.
iterator erase (const_iterator first, const_iterator last)
 Erases a range of elements.
iterator find (key_parameter_t key)
 Finds an element.
const_iterator find (key_parameter_t key) const
 Finds an element.
std::pair< iterator, bool > insert (const value_type &value)
 Inserts a value to the map.
iterator insert (iterator, const value_type &value)
 Inserts a value to the map starting at the position recommended.
iterator insert (const_iterator, const value_type &value)
 Inserts a value to the map starting at the position recommended.
void insert (TIterator first, TIterator last)
 Inserts a range of values to the map.
iterator lower_bound (key_parameter_t key)
 Returns an iterator pointing to the first element in the container whose key is not considered to go before the key provided or end() if all keys are considered to go before the key provided.
const_iterator lower_bound (key_parameter_t key) const
 Returns a const_iterator pointing to the first element in the container whose key is not considered to go before the key provided or end() if all keys are considered to go before the key provided.
iterator upper_bound (key_parameter_t key)
 Returns an iterator pointing to the first element in the container whose key is not considered to go after the key provided or end() if all keys are considered to go after the key provided.
const_iterator upper_bound (key_parameter_t key) const
 Returns a const_iterator pointing to the first element in the container whose key is not considered to go after the key provided or end() if all keys are considered to go after the key provided.
size_type size () const
 Gets the size of the map.
size_type max_size () const
 Gets the maximum possible size of the map.
bool empty () const
 Checks to see if the map is empty.
bool full () const
 Checks to see if the map is full.
size_type capacity () const
 Returns the capacity of the vector.
size_t available () const
 Returns the remaining capacity.

Protected Types

typedef etl::parameter_type
< TKey >::type 
key_parameter_t
 Defines the key value parameter type.

Protected Member Functions

bool node_comp (const Data_Node &node1, const Data_Node &node2) const
 How to compare node elements.
void initialise ()
 Initialise the map.
void balance_node (Node *&critical_node)
 Balance the critical node at the position provided as needed.
void rotate_2node (Node *&position, uint_least8_t dir)
 Rotate two nodes at the position provided the to balance the tree.
void rotate_3node (Node *&position, uint_least8_t dir, uint_least8_t third)
 Rotate three nodes at the position provided the to balance the tree.
Nodefind_limit_node (Node *position, const int8_t dir) const
 Find the node whose key would go before all the other keys from the position provided.
const Nodefind_limit_node (const Node *position, const int8_t dir) const
 Find the node whose key would go before all the other keys from the position provided.
void attach_node (Node *&position, Node &node)
 Attach the provided node to the position provided.
void detach_node (Node *&position, Node *&replacement)
 Detach the node at the position provided.

Protected Attributes

size_type current_size
 The number of the used nodes.
const size_type CAPACITY
 The maximum size of the map.
Noderoot_node
 The node that acts as the map root.

Detailed Description

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

A templated map implementation that uses a fixed size buffer.

Definition at line 2006 of file map.h.


Member Typedef Documentation

typedef etl::parameter_type<TKey>::type key_parameter_t [protected, inherited]

Defines the key value parameter type.

Definition at line 510 of file map.h.

typedef size_t size_type [inherited]

The type used for determining the size of map.

Reimplemented from map_base.

Definition at line 465 of file map.h.


Constructor & Destructor Documentation

map (  )

Default constructor.

Definition at line 2015 of file map.h.

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

Copy constructor.

Definition at line 2024 of file map.h.

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 2037 of file map.h.

~map (  )

Destructor.

Definition at line 2046 of file map.h.


Member Function Documentation

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

Assigns values to the map.

If asserts or exceptions are enabled, emits map_full if the map does not have enough free space. If asserts or exceptions are enabled, emits map_iterator if the iterators are reversed.

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

Definition at line 957 of file 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::lookup_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 925 of file 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::lookup_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 940 of file map.h.

void attach_node ( Node *&  position,
Node node 
) [protected, inherited]

Attach the provided node to the position provided.

Definition at line 406 of file map.h.

size_t available (  ) const [inherited]

Returns the remaining capacity.

Returns:
The remaining capacity.

Definition at line 176 of file map.h.

void balance_node ( Node *&  critical_node ) [protected, inherited]

Balance the critical node at the position provided as needed.

Definition at line 239 of file map.h.

iterator begin (  ) [inherited]

Gets the beginning of the map.

Definition at line 808 of file map.h.

const_iterator begin (  ) const [inherited]

Gets the beginning of the map.

Definition at line 816 of file map.h.

size_type capacity (  ) const [inherited]

Returns the capacity of the vector.

Returns:
The capacity of the vector.

Definition at line 167 of file map.h.

const_iterator cbegin (  ) const [inherited]

Gets the beginning of the map.

Definition at line 840 of file map.h.

const_iterator cend (  ) const [inherited]

Gets the end of the map.

Definition at line 848 of file map.h.

void clear (  ) [inherited]

Clears the map.

Definition at line 966 of file map.h.

size_type count ( key_parameter_t  key ) const [inherited]

Counts the number of elements that contain the key specified.

Parameters:
keyThe key to search for.
Returns:
1 if element was found, 0 otherwise.

Definition at line 976 of file map.h.

const_reverse_iterator crbegin (  ) const [inherited]

Gets the reverse beginning of the list.

Definition at line 888 of file map.h.

const_reverse_iterator crend (  ) const [inherited]

Gets the reverse end of the list.

Definition at line 896 of file map.h.

void detach_node ( Node *&  position,
Node *&  replacement 
) [protected, inherited]

Detach the node at the position provided.

Definition at line 421 of file map.h.

bool empty (  ) const [inherited]

Checks to see if the map is empty.

Definition at line 150 of file map.h.

const_iterator end (  ) const [inherited]

Gets the end of the map.

Definition at line 832 of file map.h.

iterator end (  ) [inherited]

Gets the end of the map.

Definition at line 824 of file map.h.

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

Returns two iterators with bounding (lower bound, upper bound) the key provided.

Definition at line 985 of file map.h.

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

Returns two const iterators with bounding (lower bound, upper bound) the key provided.

Definition at line 996 of file map.h.

void erase ( iterator  position ) [inherited]

Erases the value at the specified position.

Definition at line 1006 of file map.h.

iterator erase ( iterator  first,
iterator  last 
) [inherited]

Erases a range of elements.

Definition at line 1039 of file map.h.

iterator erase ( const_iterator  first,
const_iterator  last 
) [inherited]

Erases a range of elements.

Definition at line 1053 of file map.h.

iterator erase ( const_iterator  position ) [inherited]

Erases the value at the specified position.

Definition at line 1015 of file 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 1069 of file 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 1079 of file map.h.

Node* find_limit_node ( Node position,
const int8_t  dir 
) const [protected, inherited]

Find the node whose key would go before all the other keys from the position provided.

Definition at line 373 of file map.h.

const Node* find_limit_node ( const Node position,
const int8_t  dir 
) const [protected, inherited]

Find the node whose key would go before all the other keys from the position provided.

Definition at line 390 of file map.h.

bool full (  ) const [inherited]

Checks to see if the map is full.

Definition at line 158 of file map.h.

void initialise (  ) [protected, inherited]

Initialise the map.

Definition at line 1242 of file map.h.

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

Inserts a value to the map.

If asserts or exceptions are enabled, emits map_full if the map is already full.

Parameters:
valueThe value to insert.

Definition at line 1089 of file map.h.

iterator insert ( iterator  ,
const value_type &  value 
) [inherited]

Inserts a value to the map starting at the position recommended.

If asserts or exceptions are enabled, emits map_full if the map is already full.

Parameters:
positionThe position that would precede the value to insert.
valueThe value to insert.

Definition at line 1114 of file map.h.

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

Inserts a value to the map starting at the position recommended.

If asserts or exceptions are enabled, emits map_full if the map is already full.

Parameters:
positionThe position that would precede the value to insert.
valueThe value to insert.

Definition at line 1137 of file map.h.

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

Inserts a range of values to the map.

If asserts or exceptions are enabled, emits map_full if the map 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 1162 of file map.h.

iterator lower_bound ( key_parameter_t  key ) [inherited]

Returns an iterator pointing to the first element in the container whose key is not considered to go before the key provided or end() if all keys are considered to go before the key provided.

Returns:
An iterator pointing to the element not before key or end()

Definition at line 1176 of file map.h.

const_iterator lower_bound ( key_parameter_t  key ) const [inherited]

Returns a const_iterator pointing to the first element in the container whose key is not considered to go before the key provided or end() if all keys are considered to go before the key provided.

Returns:
An const_iterator pointing to the element not before key or end()

Definition at line 1187 of file map.h.

size_type max_size (  ) const [inherited]

Gets the maximum possible size of the map.

Definition at line 142 of file map.h.

bool node_comp ( const Data_Node &  node1,
const Data_Node &  node2 
) const [protected, inherited]

How to compare node elements.

Definition at line 515 of file map.h.

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

Assignment operator.

Definition at line 2054 of file 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 906 of file map.h.

reverse_iterator rbegin (  ) [inherited]

Gets the reverse beginning of the list.

Definition at line 856 of file map.h.

const_reverse_iterator rbegin (  ) const [inherited]

Gets the reverse beginning of the list.

Definition at line 864 of file map.h.

reverse_iterator rend (  ) [inherited]

Gets the reverse end of the list.

Definition at line 872 of file map.h.

const_reverse_iterator rend (  ) const [inherited]

Gets the reverse end of the list.

Definition at line 880 of file map.h.

void rotate_2node ( Node *&  position,
uint_least8_t  dir 
) [protected, inherited]

Rotate two nodes at the position provided the to balance the tree.

Definition at line 302 of file map.h.

void rotate_3node ( Node *&  position,
uint_least8_t  dir,
uint_least8_t  third 
) [protected, inherited]

Rotate three nodes at the position provided the to balance the tree.

Definition at line 332 of file map.h.

size_type size (  ) const [inherited]

Gets the size of the map.

Definition at line 134 of file map.h.

const_iterator upper_bound ( key_parameter_t  key ) const [inherited]

Returns a const_iterator pointing to the first element in the container whose key is not considered to go after the key provided or end() if all keys are considered to go after the key provided.

Returns:
An const_iterator pointing to the element after key or end()

Definition at line 1209 of file map.h.

iterator upper_bound ( key_parameter_t  key ) [inherited]

Returns an iterator pointing to the first element in the container whose key is not considered to go after the key provided or end() if all keys are considered to go after the key provided.

Returns:
An iterator pointing to the element after key or end()

Definition at line 1198 of file map.h.


Field Documentation

const size_type CAPACITY [protected, inherited]

The maximum size of the map.

Definition at line 443 of file map.h.

size_type current_size [protected, inherited]

The number of the used nodes.

Definition at line 442 of file map.h.

Node* root_node [protected, inherited]

The node that acts as the map root.

Definition at line 444 of file map.h.