ra_map.hpp
This file defines a Random Access Map template.
A random access map allows for simple traversal by index and a guarantee that a value at a given index will always be at that index unless any map element is deleted. This allows storage of indices for maps with a fixed layout, resulting in easy access.
Note
Status: ALPHA
-
template<typename KEY_T, typename T, typename Hash = std::hash<KEY_T>, typename KeyEqual = std::equal_to<KEY_T>, typename Allocator = std::allocator<std::pair<const KEY_T, T>>>
class ra_map - #include <ra_map.hpp>
This class uses a combination of a hashtable (std::unordered_map) and vector to lookup insert, lookup, and delete values in constant time, while still being able to step through all values (albeit in an arbitrary order).
Note
The arbitrary order of values may change if any values are deleted.
Public Types
-
using reference = value_type&
-
using const_reference = const value_type&
-
using layout_t = unordered_map<KEY_T, size_t, Hash, KeyEqual>
Public Functions
-
ra_map() = default
-
inline auto begin()
-
inline auto cbegin() const
-
inline auto end()
-
inline auto cend() const
-
inline size_t insert(const value_type &v)
Insert a new value into container by copy; return position.
-
inline size_t insert(value_type &&v)
Insert a new value into container by move; return position.
Private Members
-
vector<value_type> vals
Vector of all values.
-
using reference = value_type&