1 #ifndef CASM_unique_map_HH
2 #define CASM_unique_map_HH
17 template<
typename TransformFunc,
typename MapIteratorType>
24 typedef typename std::result_of<TransformFunc(typename MapIteratorType::reference)>::type
reference;
25 typedef typename std::remove_reference<reference>::type
value_type;
34 template<
typename T,
typename M>
39 template<
typename T,
typename M>
41 return (!
operator!=(B));
44 template<
typename T,
typename M>
87 MapIteratorType
base()
const {
98 template<
typename MapType>
101 typedef typename MapType::iterator::reference
reference;
102 typedef typename MapType::iterator::value_type::second_type &
result_type;
112 template<
typename MapType>
115 typedef typename MapType::const_iterator::reference
reference;
116 typedef const typename MapType::const_iterator::value_type::second_type &
result_type;
136 template<
typename KeyType,
138 typename MapType = std::map<KeyType, ValueType>,
139 typename TransformFunction = GetSecond<MapType>,
140 typename ConstTransformFunction = GetSecondConst<MapType> >
148 typedef std::function<typename MapType::mapped_type(const ValueType &)>
ConvertType;
160 explicit unique_map(KeyFuncType keyfunc, ConvertType _converter) :
164 key_type
key(
const value_type &value)
const {
169 std::pair<iterator, bool>
insert(
const value_type &value) {
174 iterator
insert(const_iterator hint,
const value_type &value) {
184 iterator
insert(iterator hint,
const value_type &value) {
194 template<
typename... ValuesOrMaps>
195 void insert(
const ValuesOrMaps &... more) {
200 template<
typename Iterator>
202 for(
auto it = begin; it !=
end; ++it) {
219 const_iterator
find(
const key_type &
key)
const {
227 iterator
erase(const_iterator pos) {
231 iterator
erase(const_iterator first, const_iterator last) {
236 return m_map.erase(key);
244 return m_map.empty();
263 const_iterator
end()
const {
275 std::pair<iterator, bool>
_insert(
const value_type &value) {
277 return std::make_pair(
iterator(result.first), result.second);
281 template<
typename A,
typename B,
typename C,
typename D,
typename E>
std::function< KeyType(const ValueType &)> KeyFuncType
size_type erase(const key_type &key)
void insert(Iterator begin, Iterator end, typename CASM::CASM_TMP::enable_if_iterator< Iterator >::type *=nullptr)
Iterator range insert.
int _insert(const unique_map< A, B, C, D, E > &value)
Dictionary insert.
const_iterator begin() const
An iterator over a UniqueMap.
UniqueMapIterator operator++(int)
std::remove_reference< reference >::type value_type
value_type & operator[](const key_type &key)
bool operator==(const UniqueMapIterator< T, M > &B) const
reference operator*() const
MapType::iterator::reference reference
UniqueMapIterator(MapIteratorType map_it)
pointer operator->() const
MapType::const_iterator ConstMapIterator
const_iterator find(const key_type &key) const
key_type key(const value_type &value) const
std::pair< iterator, bool > insert(const value_type &value)
Insert single value.
UniqueMapIterator< TransformFunction, MapIterator > iterator
iterator insert(iterator hint, const value_type &value)
Insert single value.
MapType::iterator::value_type::second_type & result_type
bool operator!=(const UniqueMapIterator< T, M > &B) const
std::function< typename MapType::mapped_type(const ValueType &)> ConvertType
iterator erase(const_iterator pos)
result_type operator()(reference pair) const
UniqueMapIterator & operator++()
UniqueMapIterator< ConstTransformFunction, ConstMapIterator > const_iterator
iterator insert(const_iterator hint, const value_type &value)
Insert single value.
void insert(const ValuesOrMaps &...more)
Variadic insert accepts as const UniqueMap& or const ValueType&.
iterator find(const key_type &key)
MapIteratorType base() const
iterator erase(const_iterator first, const_iterator last)
Non-std smart pointer classes and functions.
MapType::iterator MapIterator
UniqueMapIterator(const UniqueMapIterator< T, M > &umap_it)
const_iterator end() const
const MapType::const_iterator::value_type::second_type & result_type
unique_map(KeyFuncType keyfunc, ConvertType _converter)
std::map wrapper to enforce a 1-1 ValueType->KeyType relationship
std::enable_if< is_iterator< T >::type::value, void > enable_if_iterator
Template alias to enable a template function via SFINAE for any iterator.
UniqueMapIterator operator--(int)
std::pair< iterator, bool > _insert(const value_type &value)
Copy insert.
void ignore_returnvalues(Args &&...)
Enables calling a function on each argument in a parameter pack.
result_type operator()(reference pair) const
MapType::size_type size_type
std::bidirectional_iterator_tag iterator_category
UniqueMapIterator & operator--()
const_iterator cend() const
std::result_of< TransformFunc(typename MapIteratorType::reference)>::type reference
MapType::const_iterator::reference reference
MapIteratorType::difference_type difference_type
TransformFunc m_transform
const_iterator cbegin() const