Template Class MemoryMap

Nested Relationships

Class Documentation

template<typename V>
class umpire::util::MemoryMap

A fast replacement for std::map<void*,Value> for a generic Value.

This uses FixedMallocPool and Judy arrays and provides forward const and non-const iterators.

Public Types

using Key = void*
using Value = V
using KeyValuePair = std::pair<Key, Value*>
using Iterator = Iterator_<false>
using ConstIterator = Iterator_<true>

Public Functions

MemoryMap(const MemoryMap&) = delete
std::pair<Iterator, bool> insert(Key ptr, const Value &val) noexcept

Insert Value at ptr in the map if ptr does not exist. Uses copy constructor on Value once.


Pair of iterator position into map and boolean value whether entry was added. The iterator will be set to end() if no insertion was made.

template<typename P>
std::pair<Iterator, bool> insert(P &&pair) noexcept

Insert a key-value pair if pair.first does not exist as a key. Must have first and second fields. Calls the first version.


See alternative version.

template<typename ...Args>
std::pair<Iterator, bool> insert(Key ptr, Args&&... args) noexcept

Emplaces a new value at ptr in the map, forwarding args to the placement new constructor.


See alternative version.

Iterator findOrBefore(Key ptr) noexcept

Find a value at ptr.


iterator into map at ptr or preceeding position.

ConstIterator findOrBefore(Key ptr) const noexcept
Iterator find(Key ptr) noexcept

Find a value at ptr.


iterator into map at ptr or end() if not found.

ConstIterator find(Key ptr) const noexcept
ConstIterator begin() const

Iterator to first value or end() if empty.

Iterator begin()
ConstIterator end() const

Iterator to one-past-last value.

Iterator end()
void erase(Key ptr)

Remove an entry from the map.

void erase(Iterator iter)
void erase(ConstIterator oter)
void removeLast()

Remove/deallocate the last found entry.

WARNING: Use this with caution, only directly after using a method above. erase(Key) is safer, but requires an additional lookup.

void clear() noexcept

Clear all entris from the map.

std::size_t size() const noexcept

Return number of entries in the map.

template<typename ...Args>
std::pair<typename MemoryMap<V>::Iterator, bool> doInsert(Key ptr, Args&&... args) noexcept
template<typename P>
std::pair<typename MemoryMap<V>::Iterator, bool> insert(P &&pair) noexcept
template<typename ...Args>
std::pair<typename MemoryMap<V>::Iterator, bool> insert(Key ptr, Args&&... args) noexcept


friend class Iterator_
template<bool Const = false>
class Iterator_

Public Types

using iterator_category = std::forward_iterator_tag
using value_type = Value
using difference_type = std::ptrdiff_t
using pointer = value_type*
using reference = value_type&
using Map = typename std::conditional<Const, const MemoryMap<Value>, MemoryMap<Value>>::type
using ValuePtr = typename std::conditional<Const, const Value*, Value*>::type
using Content = std::pair<Key, ValuePtr>
using Reference = typename std::conditional<Const, const Content&, Content&>::type
using Pointer = typename std::conditional<Const, const Content*, Content*>::type

Public Functions

Iterator_(Map *map, Key ptr)
Iterator_(Map *map, iterator_begin)
Iterator_(Map *map, iterator_end)
template<bool OtherConst>
Iterator_(const Iterator_<OtherConst> &other)
Reference operator*()
Pointer operator->()
Iterator_ &operator++()
Iterator_ operator++(int)
template<bool OtherConst>
bool operator==(const Iterator_<OtherConst> &other) const
template<bool OtherConst>
bool operator!=(const Iterator_<OtherConst> &other) const
template<bool OtherConst>
bool operator==(const MemoryMap<V>::Iterator_<OtherConst> &other) const
template<bool OtherConst>
bool operator!=(const MemoryMap<V>::Iterator_<OtherConst> &other) const