|
gem5 [DEVELOP-FOR-25.0]
|
A trie is a tree-based data structure used for data retrieval. More...
#include <trie.hh>
Classes | |
| struct | Node |
Public Types | |
| typedef Node * | Handle |
Public Member Functions | |
| Trie () | |
| Handle | insert (Key key, unsigned width, Value *val) |
| Method which inserts a key/value pair into the trie. | |
| Value * | lookup (Key key) |
| Method which looks up the Value corresponding to a particular key. | |
| Value * | remove (Handle handle) |
| Method to delete a value from the trie. | |
| Value * | remove (Key key) |
| Method to lookup a value from the trie and then delete it. | |
| void | clear () |
| A method which removes all key/value pairs from the trie. | |
| void | dump (const char *title, std::ostream &os=std::cout) |
| A debugging method which prints the contents of this trie. | |
Static Public Attributes | |
| static const unsigned | MaxBits = sizeof(Key) * 8 |
Protected Attributes | |
| Node | head |
Private Member Functions | |
| bool | goesAfter (Node **parent, Node *kid, Key key, Key new_mask) |
| A utility method which checks whether the key being looked up lies beyond the Node being examined. | |
| Key | extendMask (Key orig) |
| A utility method which extends a mask value one more bit towards the lsb. | |
| Handle | lookupHandle (Key key) |
| Method which looks up the Handle corresponding to a particular key. | |
A trie is a tree-based data structure used for data retrieval.
It uses bits masked from the msb of the key to to determine a value's location, so its lookups have their worst case time dictated by the key's size.
| Key | Type of the key of the tree nodes. Must be an integral type. |
| Value | Type of the values associated to the keys. |
|
inline |
|
inlineprivate |
A utility method which extends a mask value one more bit towards the lsb.
This is almost just a signed right shift, except that the shifted in bits are technically undefined. This is also slightly complicated by the zero case.
| orig | The original mask to extend. |
Definition at line 160 of file trie.hh.
Referenced by gem5::Trie< Addr, TlbEntry >::insert().
|
inlineprivate |
A utility method which checks whether the key being looked up lies beyond the Node being examined.
If so, it returns true and advances the node being examined.
| parent | The node we're currently "at", which can be updated. |
| kid | The node we may want to move to. |
| key | The key we're looking for. |
| new_mask | The mask to use when matching against the key. |
Definition at line 141 of file trie.hh.
Referenced by gem5::Trie< Addr, TlbEntry >::insert().
|
inlineprivate |
Method which looks up the Handle corresponding to a particular key.
This is useful if you want to delete the Handle corresponding to a key since the "remove" function takes a Handle as its argument.
| key | The key to look up. |
Definition at line 175 of file trie.hh.
Referenced by gem5::Trie< Addr, TlbEntry >::lookup(), and gem5::Trie< Addr, TlbEntry >::remove().
|
protected |