mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer > Class Template Reference

Lightweight c++11 dictionary map implementation. More...

#include <mn_basic_light_map.hpp>

+ Collaboration diagram for mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >:

Public Types

using mapped_type = TValue
 
using key_type = TKey
 
using value_type = TPairType
 
using reference = TPairType &
 
using pointer = TPairType *
 
using const_reference = const TPairType &
 
using const_pointer = const TPairType *
 
using difference_type = mn::ptrdiff_t
 
using size_type = mn::size_t
 
using iterator = TValue *
 
using const_iterator = const TValue *
 
using self_type = basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >
 

Public Member Functions

 basic_light_map (const size_type start_size=32) noexcept
 
 ~basic_light_map ()
 
void clear ()
 
template<class... Args>
mn::container::pair< iterator, bool > assign (const key_type &key, Args &&... args)
 
mn::container::pair< iterator, bool > assign (const value_type &vValue)
 
template<class... Args>
mn::container::pair< iterator, bool > emplace (const key_type &key, Args &&... args)
 Inserts a new element into the container constructed in-place with the given args if there is no element with the key in the container. More...
 
mn::container::pair< iterator, bool > insert (const value_type &value)
 Inserts value. More...
 
template<class... Args>
void insert_or_assign (const key_type &key, Args &&... args)
 
bool insert (const key_type &key, const mapped_type &value)
 insert key_type key with mapped_type value. More...
 
bool insert (key_type &&key, mapped_type &&value)
 insert key_type key with mapped_type value. More...
 
iterator erase (const_iterator pos)
 Removes specified elements from the container. More...
 
iterator erase (const_iterator first, const_iterator last)
 Removes specified elements from the container. More...
 
size_type erase (const key_type &tKey)
 Removes the element with the key equivalent to tKey. More...
 
iterator find (const key_type &tKey) noexcept
 Finds an element with key equivalent to key. More...
 
const_iterator find (const key_type &tKey) const noexcept
 Finds an element with key equivalent to key. More...
 
constexpr bool empty () const noexcept
 Is the map empty. More...
 
constexpr size_type size () const noexcept
 Get the number of map-members. More...
 
size_type count (const key_type &key) const
 Returns the number of elements with key key. More...
 
void swap (self_type &other)
 Exchanges the contents of the container with those of other. More...
 
iterator operator[] (const key_type &tKey) noexcept
 Read value of map for given key. More...
 
const_iterator operator[] (const key_type &tKey) const noexcept
 Read value of map for given key. More...
 

Private Attributes

TContainer m_ayKeyValue
 

Detailed Description

template<class TKey, class TValue, class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
class mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >

Lightweight c++11 dictionary map implementation.

Template Parameters
TKeyThe type for the key.
TValueThe type for the value.
TPairTypeThe using type for the Key:Value-pair.
TArrayTypeThe using type for holding the pairs.

Member Typedef Documentation

◆ const_iterator

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::const_iterator = const TValue*

◆ const_pointer

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::const_pointer = const TPairType*

◆ const_reference

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::const_reference = const TPairType&

◆ difference_type

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::difference_type = mn::ptrdiff_t

◆ iterator

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::iterator = TValue*

◆ key_type

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::key_type = TKey

◆ mapped_type

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::mapped_type = TValue

◆ pointer

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::pointer = TPairType*

◆ reference

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::reference = TPairType&

◆ self_type

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::self_type = basic_light_map < TKey, TValue, TALLOCATOR, TPairType, TContainer>

◆ size_type

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::size_type = mn::size_t

◆ value_type

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
using mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::value_type = TPairType

Constructor & Destructor Documentation

◆ basic_light_map()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::basic_light_map ( const size_type  start_size = 32)
inlinenoexcept

◆ ~basic_light_map()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::~basic_light_map ( )
inline

Member Function Documentation

◆ assign() [1/2]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
template<class... Args>
mn::container::pair<iterator, bool> mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::assign ( const key_type key,
Args &&...  args 
)
inline

◆ assign() [2/2]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
mn::container::pair<iterator, bool> mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::assign ( const value_type vValue)
inline

◆ clear()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
void mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::clear ( )
inline

◆ count()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
size_type mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::count ( const key_type key) const
inline

Returns the number of elements with key key.

Parameters
keyValue of the elements to count.
Returns
Number of elements with key that compares equivalent to key, which is either 1 or 0.

◆ emplace()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
template<class... Args>
mn::container::pair<iterator, bool> mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::emplace ( const key_type key,
Args &&...  args 
)
inline

Inserts a new element into the container constructed in-place with the given args if there is no element with the key in the container.

Parameters
keyThe key to emplace.
argsarguments to forward to the constructor of the element.
Returns
Returns a pair consisting of an iterator to the inserted element, and a bool denoting whether the insertion took place (true if insertion happened and false if not).

◆ empty()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
constexpr bool mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::empty ( ) const
inlineconstexprnoexcept

Is the map empty.

Returns
If true then is the map empty and if false then not.

◆ erase() [1/3]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
size_type mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::erase ( const key_type tKey)
inline

Removes the element with the key equivalent to tKey.

Parameters
tKeyvalue of the elements to remove.
Returns
Number of elements removed (0 or 1).

◆ erase() [2/3]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
iterator mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Removes specified elements from the container.

Parameters
firstThe start of the range of elements to remove.
lastThe end of the range of elements to remove.
Returns
Return the the last removed iterator.

◆ erase() [3/3]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
iterator mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::erase ( const_iterator  pos)
inline

Removes specified elements from the container.

Parameters
posIterator to the element to remove.
Returns
Return the the last removed iterator.

◆ find() [1/2]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
const_iterator mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::find ( const key_type tKey) const
inlinenoexcept

Finds an element with key equivalent to key.

Parameters
tKeyThe key value of the element to search for.
Returns
The associerte value with this key, when not exist then return the setted alternative value.

◆ find() [2/2]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
iterator mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::find ( const key_type tKey)
inlinenoexcept

Finds an element with key equivalent to key.

Parameters
tKeyThe key value of the element to search for.
Returns
The associerte value with this key, when not exist then return the end();

◆ insert() [1/3]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
bool mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::insert ( const key_type key,
const mapped_type value 
)
inline

insert key_type key with mapped_type value.

Returns
  • True: The key doesn't exist, the data is added to the map
  • False: The key already exists, no change is made

◆ insert() [2/3]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
mn::container::pair<iterator, bool> mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::insert ( const value_type value)
inline

Inserts value.

Parameters
valueThe element value to insert.
Returns
Returns a pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

◆ insert() [3/3]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
bool mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::insert ( key_type &&  key,
mapped_type &&  value 
)
inline

insert key_type key with mapped_type value.

Returns
  • True: The key doesn't exist, the data is added to the map
  • False: The key already exists, no change is made

◆ insert_or_assign()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
template<class... Args>
void mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::insert_or_assign ( const key_type key,
Args &&...  args 
)
inline

◆ operator[]() [1/2]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
const_iterator mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::operator[] ( const key_type tKey) const
inlinenoexcept

Read value of map for given key.

Parameters
tKeyThe key.
Returns
The associerte value with this key, when not exist then return the setted alternative value.

◆ operator[]() [2/2]

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
iterator mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::operator[] ( const key_type tKey)
inlinenoexcept

Read value of map for given key.

Parameters
tKeyThe key.
Returns
The associerte value with this key, when not exist then return the setted alternative value.

◆ size()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
constexpr size_type mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::size ( ) const
inlineconstexprnoexcept

Get the number of map-members.

Returns
The number of map entries.

◆ swap()

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
void mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::swap ( self_type other)
inline

Exchanges the contents of the container with those of other.

Parameters
otherContainer to exchange the contents with.

Member Data Documentation

◆ m_ayKeyValue

template<class TKey , class TValue , class TALLOCATOR = memory::default_allocator, class TPairType = mn::container::pair<TKey, TValue>, class TContainer = mn::container::vector<TPairType, TALLOCATOR>>
TContainer mn::container::basic_light_map< TKey, TValue, TALLOCATOR, TPairType, TContainer >::m_ayKeyValue
private

The documentation for this class was generated from the following file: