Public Member Functions | Private Member Functions | Private Attributes | List of all members
PLMD::Tools::FastStringUnorderedMap< T > Class Template Reference

Tiny class implementing faster std::string_view access to an unordered_map It exposes a limited number of methods of std::unordered_map. More...

#include <Tools.h>

Inheritance diagram for PLMD::Tools::FastStringUnorderedMap< T >:
Inheritance graph
[legend]

Public Member Functions

 FastStringUnorderedMap ()=default
 
 FastStringUnorderedMap (std::initializer_list< std::pair< const std::string_view, T >> init)
 
auto begin ()
 
auto begin () const
 
auto end ()
 
auto end () const
 
auto find (const std::string_view &key)
 
auto find (const std::string_view &key) const
 
T & operator[] (const std::string_view &key)
 

Private Member Functions

std::unique_ptr< const char[]> conv (std::string_view str)
 

Private Attributes

std::vector< std::unique_ptr< const char[]> > keys
 
std::unordered_map< std::string_view, T > map
 

Detailed Description

template<class T>
class PLMD::Tools::FastStringUnorderedMap< T >

Tiny class implementing faster std::string_view access to an unordered_map It exposes a limited number of methods of std::unordered_map.

Others could be added. Importantly, when it is accessed via a std::string_view, the access does not require constructing a std::string and is thus faster. Deletion would be slower instead. It's not even implemented yet.

Constructor & Destructor Documentation

◆ FastStringUnorderedMap() [1/2]

template<class T >
PLMD::Tools::FastStringUnorderedMap< T >::FastStringUnorderedMap ( )
default

◆ FastStringUnorderedMap() [2/2]

template<class T >
PLMD::Tools::FastStringUnorderedMap< T >::FastStringUnorderedMap ( std::initializer_list< std::pair< const std::string_view, T >>  init)
inline

Member Function Documentation

◆ begin() [1/2]

template<class T >
auto PLMD::Tools::FastStringUnorderedMap< T >::begin ( )
inline

◆ begin() [2/2]

template<class T >
auto PLMD::Tools::FastStringUnorderedMap< T >::begin ( ) const
inline

◆ conv()

template<class T >
std::unique_ptr<const char[]> PLMD::Tools::FastStringUnorderedMap< T >::conv ( std::string_view  str)
inlineprivate

◆ end() [1/2]

template<class T >
auto PLMD::Tools::FastStringUnorderedMap< T >::end ( )
inline

◆ end() [2/2]

template<class T >
auto PLMD::Tools::FastStringUnorderedMap< T >::end ( ) const
inline

◆ find() [1/2]

template<class T >
auto PLMD::Tools::FastStringUnorderedMap< T >::find ( const std::string_view &  key)
inline

◆ find() [2/2]

template<class T >
auto PLMD::Tools::FastStringUnorderedMap< T >::find ( const std::string_view &  key) const
inline

◆ operator[]()

template<class T >
T& PLMD::Tools::FastStringUnorderedMap< T >::operator[] ( const std::string_view &  key)
inline

Member Data Documentation

◆ keys

template<class T >
std::vector<std::unique_ptr<const char[]> > PLMD::Tools::FastStringUnorderedMap< T >::keys
private

◆ map

template<class T >
std::unordered_map<std::string_view,T> PLMD::Tools::FastStringUnorderedMap< T >::map
private

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