13 #ifndef __STOUT_LINKEDHASHMAP_HPP__
14 #define __STOUT_LINKEDHASHMAP_HPP__
28 template <
typename Key,
typename Value>
32 typedef std::pair<Key, Value>
entry;
33 typedef std::list<entry>
list;
39 : entries_(other.entries_)
42 for (
auto it = entries_.begin(); it != entries_.end(); ++it) {
43 keys_[it->first] = it;
51 entries_ = other.entries_;
54 for (
auto it = entries_.begin(); it != entries_.end(); ++it) {
55 keys_[it->first] = it;
70 typename list::iterator iter =
71 entries_.insert(entries_.end(), std::make_pair(key, Value()));
76 return keys_[key]->second;
82 return keys_.at(key)->second;
87 Value&
at(
const Key& key)
89 return keys_.at(key)->second;
92 const Value&
at(
const Key& key)
const
94 return keys_.at(key)->second;
105 typename list::iterator iter = keys_[key];
107 entries_.erase(iter);
116 std::list<Key> result;
119 result.push_back(entry.first);
128 std::list<Value> result;
131 result.push_back(entry.second);
144 return keys_.empty();
156 typename list::iterator
begin() {
return entries_.begin(); }
157 typename list::iterator
end() {
return entries_.end(); }
159 typename list::const_iterator
begin()
const {
return entries_.cbegin(); }
160 typename list::const_iterator
end()
const {
return entries_.cend(); }
168 #endif // __STOUT_LINKEDHASHMAP_HPP__
bool empty() const
Definition: linkedhashmap.hpp:142
Definition: option.hpp:28
const Value & at(const Key &key) const
Definition: linkedhashmap.hpp:92
LinkedHashMap(const LinkedHashMap< Key, Value > &other)
Definition: linkedhashmap.hpp:38
std::pair< Key, Value > entry
Definition: linkedhashmap.hpp:32
std::list< Key > keys() const
Definition: linkedhashmap.hpp:114
list::const_iterator begin() const
Definition: linkedhashmap.hpp:159
size_t size() const
Definition: linkedhashmap.hpp:137
list::const_iterator end() const
Definition: linkedhashmap.hpp:160
size_t erase(const Key &key)
Definition: linkedhashmap.hpp:102
hashmap< Key, typename list::iterator > map
Definition: linkedhashmap.hpp:34
list::iterator begin()
Definition: linkedhashmap.hpp:156
Value & at(const Key &key)
Definition: linkedhashmap.hpp:87
Value & operator[](const Key &key)
Definition: linkedhashmap.hpp:65
LinkedHashMap & operator=(const LinkedHashMap< Key, Value > &other)
Definition: linkedhashmap.hpp:47
void clear()
Definition: linkedhashmap.hpp:147
Definition: linkedhashmap.hpp:29
bool contains(const Key &key) const
Definition: linkedhashmap.hpp:97
bool contains(const Key &key) const
Definition: hashmap.hpp:86
list::iterator end()
Definition: linkedhashmap.hpp:157
std::list< Value > values() const
Definition: linkedhashmap.hpp:126
std::list< entry > list
Definition: linkedhashmap.hpp:33