12#ifndef BELFEM_CL_MAP_HPP
13#define BELFEM_CL_MAP_HPP
15#include <unordered_map>
29 template <
typename T >
47 return std::to_string( aKey );
54 return std::to_string( aKey );
61 return std::to_string( aKey );
73 template<
typename Key,
typename Value >
77 std::unordered_map< Key, Value > mMap;
83 using const_iterator =
typename std::unordered_map< Key, Value >::const_iterator ;
88 explicit Map() =
default;
163 return mMap.find( aKey ) != mMap.end();
181 find (
const Key & tKey )
const ->
decltype( mMap.find(tKey) )
183 return mMap.find( tKey );
196 "Map::get_entry() index %lu out of bounds ( must be < %lu )",
197 (
long unsigned int ) aIndex,
198 (
long unsigned int ) mMap.size() );
200 auto tEntry = mMap.begin();
201 std::advance( tEntry, aIndex );
203 const auto & aEntry = * tEntry;
233 auto tIterator = mMap.find( aKey );
235#if !defined( NDEBUG ) || defined( DEBUG )
237 "Key %s not found in map.",
242 "Key not found in map." );
245 return tIterator->second;
257 auto tIterator = mMap.find( aKey );
259#if !defined( NDEBUG ) || defined( DEBUG )
262 "Key %s not found in map.",
267 "Key not found in map." );
270 return tIterator->second;
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
void clear()
clear map
Definition cl_Map.hpp:131
auto empty() const -> decltype(mMap.empty())
Definition cl_Map.hpp:187
Value & operator()(const Key &aKey)
find operator
Definition cl_Map.hpp:230
auto get_entry(const index_t aIndex) const -> decltype(*mMap.begin())
Definition cl_Map.hpp:193
bool key_exists(const Key &aKey) const
Definition cl_Map.hpp:161
~Map()=default
default destructor
Map()=default
empty constructor
typename std::unordered_map< Key, Value >::const_iterator const_iterator
Definition cl_Map.hpp:83
const Value & operator()(const Key &aKey) const
find operator ( const variant )
Definition cl_Map.hpp:254
Map(const Map< Key, Value > &aMap)=default
copy constructor
Map< Key, Value > & operator=(Map< Key, Value > &&other) noexcept=default
Move assignment operator constructor.
Value & operator[](const Key &aKey)
insert operator
Definition cl_Map.hpp:153
auto end() const -> decltype(mMap.end())
Definition cl_Map.hpp:175
Map(Map< Key, Value > &&other) noexcept=default
move constructor
Map< Key, Value > & operator=(const Map< Key, Value > &other)=default
Copy assignment operator.
auto begin() const -> decltype(mMap.begin())
Definition cl_Map.hpp:169
size_t size() const
returns the size of the map
Definition cl_Map.hpp:142
auto map_data() -> decltype(mMap) &
Definition cl_Map.hpp:219
auto find(const Key &tKey) const -> decltype(mMap.find(tKey))
Definition cl_Map.hpp:181
void erase_key(const Key &aKey)
Definition cl_Map.hpp:210
std::string KeyToString(const T &aKey)
Definition cl_Map.hpp:31
USER GUIDES:
Definition cl_Capacitor.cpp:16
uint32_t index_t
Definition typedefs.hpp:52