25 #ifndef __I6ENGINE_UTILS_SEQUENCEMAP_H__
26 #define __I6ENGINE_UTILS_SEQUENCEMAP_H__
30 #include <unordered_map>
46 template<
typename KeyType,
typename ValueType,
typename Hash = std::hash<KeyType>>
62 if (_map.find(key) == _map.end()) {
63 _list.push_back(std::make_pair(key, ValueType()));
64 _map[key] = &(_list.back().second);
79 std::size_t
erase(
const KeyType & key) {
81 for (
auto it = _list.begin(); it != _list.end(); it++) {
82 if (it->first == key) {
93 const_iterator
erase(const_iterator position) {
94 _map.erase(position->first);
95 #if ISIXE_MPLATFORM == ISIXE_MPLATFORM_WIN32
96 return _list.erase(position);
97 #elif ISIXE_MPLATFORM == ISIXE_MPLATFORM_LINUX
100 for (iterator it = _list.begin(); it != _list.end(); ++it) {
101 if (it->first == position->first) {
102 return _list.erase(it);
112 typename std::list<std::pair<KeyType, ValueType>>
::iterator find(
const KeyType & key) {
113 if (_map.find(key) == _map.end()) {
116 for (
typename std::list<std::pair<KeyType, ValueType>>::iterator it = _list.begin(); it != _list.end(); ++it) {
117 if (it->first == key) {
126 if (_map.find(key) == _map.end()) {
129 for (
typename std::list<std::pair<KeyType, ValueType>>::const_iterator it = _list.begin(); it != _list.end(); ++it) {
130 if (it->first == key) {
142 return _list.begin();
149 return _list.begin();
170 return _list.cbegin();
189 std::unordered_map<KeyType, ValueType *, Hash> _map;
191 std::list<std::pair<KeyType, ValueType>> _list;
A map with linear access time and an iterator iterating through the elements in creation time...
std::list< std::pair< KeyType, ValueType > >::const_iterator begin() const
returns const_iterator to the begin of the list
std::list< std::pair< KeyType, ValueType > >::iterator find(const KeyType &key)
returns iterator to found entry for key, otherwise end()
std::list< std::pair< KeyType, ValueType > >::const_iterator cend() const
returns const_iterator to the end of the list
std::size_t size() const
returns size of the map
std::list< std::pair< int64_t, ComPtr > >::iterator iterator
std::list< std::pair< KeyType, ValueType > >::const_iterator find(const KeyType &key) const
const_iterator erase(const_iterator position)
remove value contained by iterator
std::size_t erase(const KeyType &key)
removes value for given key, returns 1 if successful, otherwise 0
std::list< std::pair< int64_t, ComPtr > >::const_iterator const_iterator
std::list< std::pair< KeyType, ValueType > >::const_iterator end() const
returns const_iterator to the end of the list
sequence_map()
constructor
std::list< std::pair< KeyType, ValueType > >::iterator end()
returns iterator to the end of the list
std::list< std::pair< KeyType, ValueType > >::const_iterator cbegin() const
returns const_iterator to the begin of the list
std::list< std::pair< KeyType, ValueType > >::iterator begin()
returns iterator to the begin of the list
ValueType & operator[](const KeyType &key)
acess operator with [] using key, returns