|
Open Model Railroad Network (OpenMRN)
|
This is an abstraction of BSD sys/tree.h that is meant to mimic the semantics of std::map without having to link in libstdc++. More...
#include <SysMap.hxx>
Classes | |
| class | Iterator |
| This mimics an std::iterator. More... | |
| struct | Node |
| The metadata for a tree node. More... | |
| struct | Pair |
| mimic std::pair More... | |
Public Member Functions | |
| SysMap () | |
| Default Constructor which with no mapping entry limit. | |
| SysMap (size_t entries) | |
| Constructor that limits the number of mappings to a static pool. | |
| ~SysMap () | |
| Destructor. | |
| Value & | operator[] (const Key &key) |
| Find the index associated with the key and create it if does not exist. | |
| size_t | size () |
| Number of elements currently in the map. | |
| size_t | max_size () |
| Maximum theoretical number of elements in the map. | |
| void | clear () |
| Removes all elements in the map. | |
| Iterator | find (const Key &key) |
| Find an element matching the given key. | |
| Iterator | end () |
| Get an iterator index pointing one past the last element in mapping. | |
| Iterator | begin () |
| Get an iterator index pointing to the first element in the mapping. | |
| size_t | erase (Key key) |
| Remove a node from the tree. | |
| void | erase (Iterator it) |
| Remove a node from the tree. | |
Private Member Functions | |
| Node * | alloc () |
| Allocate a node from the free list. | |
| void | free (Node *node) |
| free a node to the free list if it exists. | |
| int64_t | compare (Node *a, Node *b) |
| Compare two nodes. | |
| RB_HEAD (tree, Node) | |
| The datagram tree type. | |
| RB_GENERATE (tree, Node, entry, compare) | |
| The datagram tree methods. | |
| DISALLOW_COPY_AND_ASSIGN (SysMap) | |
Private Attributes | |
| size_t | entries |
| total number of entries for this instance | |
| size_t | used |
| total number of entries in use for this instance | |
| Node * | freeList |
| list of free nodes | |
| Node * | nodes |
| location of pre-allocated Node memory | |
| struct tree | head |
| tree instance | |
This is an abstraction of BSD sys/tree.h that is meant to mimic the semantics of std::map without having to link in libstdc++.
Definition at line 45 of file SysMap.hxx.
Default Constructor which with no mapping entry limit.
Definition at line 50 of file SysMap.hxx.
Constructor that limits the number of mappings to a static pool.
| entries | number of nodes to statically create and track |
Definition at line 63 of file SysMap.hxx.
Destructor.
Definition at line 77 of file SysMap.hxx.
Allocate a node from the free list.
Definition at line 316 of file SysMap.hxx.
Get an iterator index pointing to the first element in the mapping.
Definition at line 273 of file SysMap.hxx.
|
inline |
Removes all elements in the map.
Definition at line 232 of file SysMap.hxx.
|
inlineprivate |
Compare two nodes.
They type is the largest signed type we know. This is because sys/tree.h only works with signed results on a compare.
| a | first of two nodes to compare |
| b | second of two nodes to compare |
Definition at line 364 of file SysMap.hxx.
Get an iterator index pointing one past the last element in mapping.
Definition at line 264 of file SysMap.hxx.
Remove a node from the tree.
| it | iterator index for the element to remove |
Definition at line 302 of file SysMap.hxx.
|
inline |
Remove a node from the tree.
| key | key for the element to remove |
Definition at line 284 of file SysMap.hxx.
|
inline |
Find an element matching the given key.
| key | key to search for |
Definition at line 252 of file SysMap.hxx.
|
inlineprivate |
free a node to the free list if it exists.
| node | node to free |
Definition at line 343 of file SysMap.hxx.
|
inline |
Maximum theoretical number of elements in the map.
Definition at line 226 of file SysMap.hxx.
|
inline |
Find the index associated with the key and create it if does not exist.
| key | key to lookup |
Definition at line 200 of file SysMap.hxx.
|
inline |
Number of elements currently in the map.
Definition at line 218 of file SysMap.hxx.
|
private |
total number of entries for this instance
Definition at line 382 of file SysMap.hxx.
list of free nodes
Definition at line 388 of file SysMap.hxx.
|
private |
tree instance
Definition at line 400 of file SysMap.hxx.
location of pre-allocated Node memory
Definition at line 391 of file SysMap.hxx.
|
private |
total number of entries in use for this instance
Definition at line 385 of file SysMap.hxx.