1#if !defined(RESIP_LINKEDHASHMAP_HXX)
2#define RESIP_LINKEDHASHMAP_HXX
7#include <unordered_map>
24template <
class Key,
class T,
class Hash = std::hash<Key>,
class KeyEqual = std::equal_to<Key> >
33 typedef std::list<value_type> List;
52 bool empty()
const {
return mList.empty(); }
63 typename Index::iterator i = mIndex.find(key);
64 return i == mIndex.end() ? mList.end() : i->second;
69 typename Index::const_iterator i = mIndex.find(key);
70 return i == mIndex.end() ? mList.end() :
const_iterator(i->second);
92 return std::make_pair(i,
false);
94 return std::make_pair(append(value),
true);
100 mIndex.erase(pos->first);
101 return mList.erase(pos);
106 typename Index::iterator i = mIndex.find(key);
107 if (i == mIndex.end())
111 mList.erase(i->second);
119 mList.swap(rhs.mList);
120 mIndex.swap(rhs.mIndex);
124 typedef std::unordered_map<Key, iterator, Hash, KeyEqual> Index;
128 mList.push_back(value);
129 iterator i = std::prev(mList.end());
132 mIndex.emplace(i->first, i);
145 mIndex.reserve(mList.size());
146 for (
iterator i = mList.begin(); i != mList.end(); ++i)
148 mIndex.emplace(i->first, i);
A hash map that iterates in insertion order, so a container filled while parsing (eg.
size_type count(const Key &key) const
const_iterator end() const
std::pair< const Key, T > value_type
size_type erase(const Key &key)
iterator find(const Key &key)
List::const_iterator const_iterator
T & operator[](const Key &key)
Appends a default-constructed value if key is not present.
const_iterator begin() const
void swap(LinkedHashMap &rhs) noexcept
LinkedHashMap & operator=(LinkedHashMap rhs) noexcept
LinkedHashMap(LinkedHashMap &&rhs) noexcept
List::size_type size_type
LinkedHashMap(const LinkedHashMap &rhs)
const_iterator cend() const
iterator erase(const_iterator pos)
std::pair< iterator, bool > insert(const value_type &value)
Appends value if its key is not present; otherwise leaves the existing element.
const_iterator cbegin() const
const_iterator find(const Key &key) const
dcm! – add UnusedChecking(_enum) below;