CASM  1.1.0
A Clusters Approach to Statistical Mechanics
notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction > Class Template Reference

#include <unique_map.hh>

+ Inheritance diagram for notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >:

Detailed Description

template<typename KeyType, typename ValueType, typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
class notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >

std::map wrapper to enforce a 1-1 ValueType->KeyType relationship

Template Parameters:

  • KeyType, type to use for key
  • ValueType, type to use as value
  • MapType, type of map to use internally.
    • MapType::mapped_type(ValueType)
      must be a valid constructor.
  • TransformFunction and ConstTransformFunction, unary function types, to convert MapType::iterator to ValueType& and *MapType::const_iterator to const ValueType

Definition at line 124 of file unique_map.hh.

Public Types

typedef ValueType value_type
 
typedef KeyType key_type
 
typedef std::function< KeyType(const ValueType &)> KeyFuncType
 
typedef std::function< typename MapType::mapped_type(const ValueType &)> ConvertType
 
typedef ValueType & reference
 
typedef ValueType * pointer
 
typedef MapType::iterator MapIterator
 
typedef MapType::const_iterator ConstMapIterator
 
typedef UniqueMapIterator< TransformFunction, MapIteratoriterator
 
typedef UniqueMapIterator< ConstTransformFunction, ConstMapIteratorconst_iterator
 
typedef MapType::size_type size_type
 

Public Member Functions

 unique_map (KeyFuncType keyfunc, ConvertType _converter)
 
key_type key (const value_type &value) const
 
std::pair< iterator, bool > insert (const value_type &value)
 Insert single value. More...
 
iterator insert (const_iterator hint, const value_type &value)
 Insert single value. More...
 
iterator insert (iterator hint, const value_type &value)
 Insert single value. More...
 
template<typename... ValuesOrMaps>
void insert (const ValuesOrMaps &... more)
 Variadic insert accepts as const UniqueMap& or const ValueType&. More...
 
template<typename Iterator >
void insert (Iterator begin, Iterator end, typename CASM::CASM_TMP::enable_if_iterator< Iterator >::type *=nullptr)
 Iterator range insert. More...
 
value_typeoperator[] (const key_type &key)
 
iterator find (const key_type &key)
 
const_iterator find (const key_type &key) const
 
void clear ()
 
iterator erase (const_iterator pos)
 
iterator erase (const_iterator first, const_iterator last)
 
size_type erase (const key_type &key)
 
size_type size () const
 
bool empty () const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 

Private Member Functions

std::pair< iterator, bool > _insert (const value_type &value)
 Copy insert. More...
 
template<typename A , typename B , typename C , typename D , typename E >
int _insert (const unique_map< A, B, C, D, E > &value)
 Dictionary insert. More...
 

Private Attributes

MapType m_map
 
KeyFuncType m_keyfunc
 
ConvertType m_converter
 

Member Typedef Documentation

◆ const_iterator

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef UniqueMapIterator<ConstTransformFunction, ConstMapIterator> notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::const_iterator

Definition at line 139 of file unique_map.hh.

◆ ConstMapIterator

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef MapType::const_iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::ConstMapIterator

Definition at line 135 of file unique_map.hh.

◆ ConvertType

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef std::function<typename MapType::mapped_type(const ValueType &)> notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::ConvertType

Definition at line 130 of file unique_map.hh.

◆ iterator

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef UniqueMapIterator<TransformFunction, MapIterator> notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::iterator

Definition at line 137 of file unique_map.hh.

◆ key_type

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef KeyType notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::key_type

Definition at line 127 of file unique_map.hh.

◆ KeyFuncType

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef std::function<KeyType(const ValueType &)> notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::KeyFuncType

Definition at line 128 of file unique_map.hh.

◆ MapIterator

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef MapType::iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::MapIterator

Definition at line 134 of file unique_map.hh.

◆ pointer

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef ValueType* notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::pointer

Definition at line 132 of file unique_map.hh.

◆ reference

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef ValueType& notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::reference

Definition at line 131 of file unique_map.hh.

◆ size_type

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef MapType::size_type notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::size_type

Definition at line 141 of file unique_map.hh.

◆ value_type

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
typedef ValueType notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::value_type

Definition at line 126 of file unique_map.hh.

Constructor & Destructor Documentation

◆ unique_map()

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::unique_map ( KeyFuncType  keyfunc,
ConvertType  _converter 
)
inlineexplicit

Definition at line 143 of file unique_map.hh.

Member Function Documentation

◆ _insert() [1/2]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
template<typename A , typename B , typename C , typename D , typename E >
int notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::_insert ( const unique_map< A, B, C, D, E > &  value)
inlineprivate

Dictionary insert.

Definition at line 235 of file unique_map.hh.

◆ _insert() [2/2]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
std::pair<iterator, bool> notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::_insert ( const value_type value)
inlineprivate

Copy insert.

Definition at line 227 of file unique_map.hh.

◆ begin() [1/2]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::begin ( )
inline

Definition at line 213 of file unique_map.hh.

◆ begin() [2/2]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
const_iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::begin ( ) const
inline

Definition at line 215 of file unique_map.hh.

◆ cbegin()

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
const_iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::cbegin ( ) const
inline

Definition at line 217 of file unique_map.hh.

◆ cend()

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
const_iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::cend ( ) const
inline

Definition at line 223 of file unique_map.hh.

◆ clear()

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
void notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::clear ( )
inline

Definition at line 197 of file unique_map.hh.

◆ empty()

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
bool notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::empty ( ) const
inline

Definition at line 211 of file unique_map.hh.

◆ end() [1/2]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::end ( )
inline

Definition at line 219 of file unique_map.hh.

◆ end() [2/2]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
const_iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::end ( ) const
inline

Definition at line 221 of file unique_map.hh.

◆ erase() [1/3]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
size_type notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::erase ( const key_type key)
inline

Definition at line 207 of file unique_map.hh.

◆ erase() [2/3]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Definition at line 203 of file unique_map.hh.

◆ erase() [3/3]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::erase ( const_iterator  pos)
inline

Definition at line 199 of file unique_map.hh.

◆ find() [1/2]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::find ( const key_type key)
inline

Definition at line 191 of file unique_map.hh.

◆ find() [2/2]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
const_iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::find ( const key_type key) const
inline

Definition at line 193 of file unique_map.hh.

◆ insert() [1/5]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
std::pair<iterator, bool> notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::insert ( const value_type value)
inline

Insert single value.

Definition at line 149 of file unique_map.hh.

◆ insert() [2/5]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
template<typename... ValuesOrMaps>
void notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::insert ( const ValuesOrMaps &...  more)
inline

Variadic insert accepts as const UniqueMap& or const ValueType&.

Definition at line 169 of file unique_map.hh.

◆ insert() [3/5]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::insert ( const_iterator  hint,
const value_type value 
)
inline

Insert single value.

Definition at line 154 of file unique_map.hh.

◆ insert() [4/5]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
template<typename Iterator >
void notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::insert ( Iterator  begin,
Iterator  end,
typename CASM::CASM_TMP::enable_if_iterator< Iterator >::type *  = nullptr 
)
inline

Iterator range insert.

Definition at line 175 of file unique_map.hh.

◆ insert() [5/5]

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
iterator notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::insert ( iterator  hint,
const value_type value 
)
inline

Insert single value.

Definition at line 161 of file unique_map.hh.

◆ key()

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
key_type notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::key ( const value_type value) const
inline

Definition at line 146 of file unique_map.hh.

◆ operator[]()

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
value_type& notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::operator[] ( const key_type key)
inline

Definition at line 183 of file unique_map.hh.

◆ size()

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
size_type notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::size ( ) const
inline

Definition at line 209 of file unique_map.hh.

Member Data Documentation

◆ m_converter

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
ConvertType notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::m_converter
private

Definition at line 242 of file unique_map.hh.

◆ m_keyfunc

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
KeyFuncType notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::m_keyfunc
private

Definition at line 241 of file unique_map.hh.

◆ m_map

template<typename KeyType , typename ValueType , typename MapType = std::map<KeyType, ValueType>, typename TransformFunction = GetSecond<MapType>, typename ConstTransformFunction = GetSecondConst<MapType>>
MapType notstd::unique_map< KeyType, ValueType, MapType, TransformFunction, ConstTransformFunction >::m_map
private

Definition at line 240 of file unique_map.hh.


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