Template Class MemoryMap

Nested Relationships

Class Documentation

template<typename V>
class 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

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

Public Functions

MemoryMap()
~MemoryMap()
MemoryMap(const MemoryMap&)
std::pair<typename MemoryMap<V>::Iterator, bool> insert(Key ptr, const Value &val)

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

Return

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)

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

Return

See alternative version.

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

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

Return

See alternative version.

MemoryMap<V>::Iterator findOrBefore(Key ptr)

Find a value at ptr.

Return

iterator into map at ptr or preceeding position.

MemoryMap<V>::ConstIterator findOrBefore(Key ptr) const
MemoryMap<V>::Iterator find(Key ptr)

Find a value at ptr.

Return

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

MemoryMap<V>::ConstIterator find(Key ptr) const
MemoryMap<V>::ConstIterator begin() const

Iterator to first value or end() if empty.

MemoryMap<V>::Iterator begin()
MemoryMap<V>::ConstIterator end() const

Iterator to one-past-last value.

MemoryMap<V>::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()

Clear all entris from the map.

std::size_t size() const

Return number of entries in the map.

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

Friends

friend umpire::util::MemoryMap::Iterator_
template<bool Const = false>
class Iterator_ : public std::iterator<std::forward_iterator_tag, Value>

Public Types

template<>
template<>
using Map = typename std::conditional<Const, const MemoryMap<Value>, MemoryMap<Value>>::type
template<>
template<>
using ValuePtr = typename std::conditional<Const, const Value *, Value *>::type
template<>
template<>
using Content = std::pair<Key, ValuePtr>
template<>
template<>
using Reference = typename std::conditional<Const, const Content&, Content&>::type
template<>
template<>
using Pointer = typename std::conditional<Const, const Content *, Content *>::type

Public Functions

template<>
Iterator_(Map *map, Key ptr)
template<>
Iterator_(Map *map, iterator_begin)
template<>
Iterator_(Map *map, iterator_end)
template<bool OtherConst>
Iterator_(const Iterator_<OtherConst> &other)
template<>
MemoryMap<V>::template Iterator_<Const>::Reference operator*()
template<>
MemoryMap<V>::template Iterator_<Const>::Pointer operator->()
template<>
MemoryMap<V>::template Iterator_<Const> &operator++()
template<>
MemoryMap<V>::template Iterator_<Const> 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