The Sparta Modeling Framework
|
N-Tier lookup map for sparse-representation of large memory spaces. This is essentially a M-Tree where the child lookup at each node is a simple offset computed by a rshift and mask. More...
#include <TieredMap.hpp>
Classes | |
class | const_iterator |
Const for walking contents of this map if const-qualified. More... | |
class | iterator |
Iterator for walking contents of this map. More... | |
Public Types | |
Types | |
typedef std::pair< const KeyT, ValT > | pair_t |
This map contains mappings between a unique set of keys to values. This type represents that mapping for the purposes of iteration and some queries. | |
typedef std::vector< void * > | node_t |
Node in the map tree. Each node contains up to node_size children, any of which may be. | |
Public Member Functions | |
Construction | |
TieredMap (uint64_t node_size=512) | |
Constructor. | |
~TieredMap () | |
Destructor. | |
Attributes | |
uint64_t | size () const |
Number of elements allocated in this map. | |
uint64_t | getNumTiers () const |
Number of tiers used by this map to represent the entire space containing the largest key added. Because this map is sparse, has no consistent relationship with memory use. | |
uint64_t | getNumNodes () const |
Returns the number of nodes allocated within this map. | |
uint64_t | getEstimatedMemory () const |
Returns the estimated memory use by this map in bytes. | |
Iteration | |
const_iterator | begin () const |
const_iterator | end () const |
iterator | begin () |
iterator | end () |
Search & Modify | |
void | clear () |
Clears the map. Frees all mappings and data structures. | |
const pair_t * | find (const KeyT &k) const |
Finds a mapping for key k if one exists in this map. | |
pair_t * | find (const KeyT &k) |
Overload for find. | |
ValT & | operator[] (const KeyT &k) |
Finds a value by its key. | |
const ValT & | operator[] (const KeyT &k) const |
const-qualified index operator | |
pair_t * | tryGet (const KeyT &k) |
Attempts to get a pair_t associated with the key k without modifying the data structure. | |
const pair_t * | tryGet (const KeyT &k) const |
const-qualified version of tryGet. | |
N-Tier lookup map for sparse-representation of large memory spaces. This is essentially a M-Tree where the child lookup at each node is a simple offset computed by a rshift and mask.
KeyT | Type of key. Should be an unsigned integer or behave like one |
ValT | Value to associate with key. Must be copy-assignable. Should generally be a pointer as it is stored by value internally. |
Represents some number space (e.g. an address space) using a number of tiers dependending on the data being represented.
Expected use is for Keys to be memory block indexes (e.g. addr/64) and values to be block objects.
Definition at line 39 of file TieredMap.hpp.
typedef std::vector<void*> sparta::TieredMap< KeyT, ValT >::node_t |
Node in the map tree. Each node contains up to node_size children, any of which may be.
Memory can be further saved by making this sparse itself. Most easily, a start index can be stored in addition to the vector's size.
More memory might be saved by making this a simple array instead of a vector. Performance in debug mode would definitely increase because of the removed bounds checking
Definition at line 64 of file TieredMap.hpp.
typedef std::pair<const KeyT, ValT> sparta::TieredMap< KeyT, ValT >::pair_t |
This map contains mappings between a unique set of keys to values. This type represents that mapping for the purposes of iteration and some queries.
Definition at line 52 of file TieredMap.hpp.
|
inline |
Constructor.
tier_size | Size of each node |
Definition at line 176 of file TieredMap.hpp.
|
inline |
Destructor.
Definition at line 193 of file TieredMap.hpp.
|
inline |
Definition at line 244 of file TieredMap.hpp.
|
inline |
Definition at line 242 of file TieredMap.hpp.
|
inline |
Clears the map. Frees all mappings and data structures.
Definition at line 258 of file TieredMap.hpp.
|
inline |
Definition at line 245 of file TieredMap.hpp.
|
inline |
Definition at line 243 of file TieredMap.hpp.
|
inline |
Overload for find.
Definition at line 284 of file TieredMap.hpp.
|
inline |
Finds a mapping for key k if one exists in this map.
k | Key for which a mapping will be located if one exists |
Definition at line 275 of file TieredMap.hpp.
|
inline |
Returns the estimated memory use by this map in bytes.
Definition at line 225 of file TieredMap.hpp.
|
inline |
Returns the number of nodes allocated within this map.
Definition at line 220 of file TieredMap.hpp.
|
inline |
Number of tiers used by this map to represent the entire space containing the largest key added. Because this map is sparse, has no consistent relationship with memory use.
Definition at line 215 of file TieredMap.hpp.
|
inline |
Finds a value by its key.
This can be used to get or set the value
Definition at line 298 of file TieredMap.hpp.
|
inline |
const-qualified index operator
Definition at line 307 of file TieredMap.hpp.
|
inline |
Number of elements allocated in this map.
Definition at line 208 of file TieredMap.hpp.
|
inline |
Attempts to get a pair_t associated with the key k without modifying the data structure.
k | Key for which a result pair will be located if present. |
Definition at line 322 of file TieredMap.hpp.
|
inline |
const-qualified version of tryGet.
Definition at line 352 of file TieredMap.hpp.