Template Class MemoryMap¶
Defined in File MemoryMap.hpp
Class Documentation¶
-
template<typename
V>
classumpire::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*¶
Public Functions
-
MemoryMap()¶
-
~MemoryMap()¶
-
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.
- 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) 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.
- Return
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.
- Return
See alternative version.
-
Iterator
findOrBefore(Key ptr) noexcept¶ Find a value at ptr.
- Return
iterator into map at ptr or preceeding position.
-
ConstIterator
findOrBefore(Key ptr) const noexcept¶
-
Iterator
find(Key ptr) noexcept¶ Find a value at ptr.
- Return
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.
-
ConstIterator
end() const¶ Iterator to one-past-last value.
-
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.
Friends
- friend class Iterator_
-
template<bool
Const= false>
classIterator_¶ Public Types
-
using
iterator_category= std::forward_iterator_tag¶
-
using
difference_type= std::ptrdiff_t¶
-
using
pointer= value_type*¶
-
using
reference= value_type&¶
Public Functions
-
Iterator_(Map *map, iterator_begin)¶
-
Iterator_(Map *map, iterator_end)¶
-
template<bool
OtherConst>Iterator_(const Iterator_<OtherConst> &other)¶
-
template<bool
OtherConst>
booloperator==(const Iterator_<OtherConst> &other) const¶
-
template<bool
OtherConst>
booloperator!=(const Iterator_<OtherConst> &other) const¶
-
template<bool
OtherConst>
booloperator==(const MemoryMap<V>::Iterator_<OtherConst> &other) const¶
-
template<bool
OtherConst>
booloperator!=(const MemoryMap<V>::Iterator_<OtherConst> &other) const¶
-
using
-
using