gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | List of all members
Trie< Key, Value > Class Template Reference

#include <trie.hh>

Classes

struct  Node
 

Public Types

typedef NodeHandle
 

Public Member Functions

 Trie ()
 
Handle insert (Key key, unsigned width, Value *val)
 Method which inserts a key/value pair into the trie. More...
 
Value * lookup (Key key)
 Method which looks up the Value corresponding to a particular key. More...
 
Value * remove (Handle handle)
 Method to delete a value from the trie. More...
 
Value * remove (Key key)
 Method to lookup a value from the trie and then delete it. More...
 
void clear ()
 A method which removes all key/value pairs from the trie. More...
 
void dump (const char *title)
 A debugging method which prints the contents of this trie. More...
 

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. More...
 
Key extendMask (Key orig)
 A utility method which extends a mask value one more bit towards the lsb. More...
 
Handle lookupHandle (Key key)
 Method which looks up the Handle corresponding to a particular key. More...
 

Detailed Description

template<class Key, class Value>
class Trie< Key, Value >

Definition at line 42 of file trie.hh.

Member Typedef Documentation

template<class Key, class Value>
typedef Node* Trie< Key, Value >::Handle

Definition at line 106 of file trie.hh.

Constructor & Destructor Documentation

template<class Key, class Value>
Trie< Key, Value >::Trie ( )
inline

Definition at line 108 of file trie.hh.

Member Function Documentation

template<class Key, class Value>
void Trie< Key, Value >::clear ( )
inline

A method which removes all key/value pairs from the trie.

This is more efficient than trying to remove elements individually.

Definition at line 340 of file trie.hh.

template<class Key, class Value>
void Trie< Key, Value >::dump ( const char *  title)
inline

A debugging method which prints the contents of this trie.

Parameters
titleAn identifying title to put in the dump header.

Definition at line 350 of file trie.hh.

Referenced by main().

template<class Key, class Value>
Key Trie< Key, Value >::extendMask ( Key  orig)
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.

Parameters
origThe original mask to extend.
Returns
The extended mask.

Definition at line 144 of file trie.hh.

Referenced by Trie< Addr, X86ISA::TlbEntry >::insert().

template<class Key, class Value>
bool Trie< Key, Value >::goesAfter ( Node **  parent,
Node kid,
Key  key,
Key  new_mask 
)
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.

Parameters
parentThe node we're currently "at", which can be updated.
kidThe node we may want to move to.
keyThe key we're looking for.
new_maskThe mask to use when matching against the key.
Returns
Whether the current Node was advanced.

Definition at line 125 of file trie.hh.

Referenced by Trie< Addr, X86ISA::TlbEntry >::insert().

template<class Key, class Value>
Handle Trie< Key, Value >::insert ( Key  key,
unsigned  width,
Value *  val 
)
inline

Method which inserts a key/value pair into the trie.

Parameters
keyThe key which can later be used to look up this value.
widthHow many bits of the key (from msb) should be used.
valA pointer to the value to store in the trie.
Returns
A Handle corresponding to this value.

Definition at line 186 of file trie.hh.

Referenced by X86ISA::TLB::insert(), main(), and X86ISA::TLB::unserialize().

template<class Key, class Value>
Value* Trie< Key, Value >::lookup ( Key  key)
inline

Method which looks up the Value corresponding to a particular key.

Parameters
keyThe key to look up.
Returns
The first Value matching this key, or NULL if none was found.

Definition at line 268 of file trie.hh.

Referenced by X86ISA::TLB::demapPage(), X86ISA::TLB::insert(), X86ISA::TLB::lookup(), and main().

template<class Key, class Value>
Handle Trie< Key, Value >::lookupHandle ( Key  key)
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.

Parameters
keyThe key to look up.
Returns
The first Handle matching this key, or NULL if none was found.

Definition at line 159 of file trie.hh.

Referenced by Trie< Addr, X86ISA::TlbEntry >::lookup(), and Trie< Addr, X86ISA::TlbEntry >::remove().

template<class Key, class Value>
Value* Trie< Key, Value >::remove ( Handle  handle)
inline

Method to delete a value from the trie.

Parameters
nodeA Handle to remove.
Returns
The Value pointer from the removed entry.

Definition at line 283 of file trie.hh.

Referenced by X86ISA::TLB::demapPage(), X86ISA::TLB::evictLRU(), X86ISA::TLB::flushAll(), X86ISA::TLB::flushNonGlobal(), and main().

template<class Key, class Value>
Value* Trie< Key, Value >::remove ( Key  key)
inline

Method to lookup a value from the trie and then delete it.

Parameters
keyThe key to look up and then remove.
Returns
The Value pointer from the removed entry, if any.

Definition at line 327 of file trie.hh.

Member Data Documentation

template<class Key, class Value>
Node Trie< Key, Value >::head
protected
template<class Key, class Value>
const unsigned Trie< Key, Value >::MaxBits = sizeof(Key) * 8
static

The documentation for this class was generated from the following file:

Generated on Fri Jun 9 2017 13:04:22 for gem5 by doxygen 1.8.6