26 #ifndef NFD_DAEMON_TABLE_NAME_TREE_HASHTABLE_HPP 27 #define NFD_DAEMON_TABLE_NAME_TREE_HASHTABLE_HPP 92 template<
typename N,
typename F>
97 while (node !=
nullptr) {
174 return m_buckets.size();
192 return m_buckets[bucket];
212 std::pair<const Node*, bool>
225 attach(
size_t bucket,
Node* node);
230 detach(
size_t bucket,
Node* node);
232 std::pair<const Node*, bool>
239 resize(
size_t newNBuckets);
242 std::vector<Node*> m_buckets;
245 size_t m_expandThreshold;
246 size_t m_shrinkThreshold;
252 #endif // NFD_DAEMON_TABLE_NAME_TREE_HASHTABLE_HPP
float expandLoadFactor
if hashtable has more than nBuckets*expandLoadFactor nodes, it will be expanded
size_t getNBuckets() const
size_t HashValue
a single hash value
void foreachNode(N *head, const F &func)
invoke a function for each node in a doubly linked list
HashtableOptions(size_t size=16)
constructor
std::pair< const Node *, bool > insert(const Name &name, size_t prefixLen, const HashSequence &hashes)
find or insert node for name.getPrefix(prefixLen)
Node(HashValue h, const Name &name)
HashSequence computeHashes(const Name &name, size_t prefixLen)
computes hash values for each prefix of name.getPrefix(prefixLen)
float expandFactor
when hashtable is expanded, its new size is nBuckets*expandFactor
const Node * getBucket(size_t bucket) const
size_t computeBucketIndex(HashValue h) const
HashValue computeHash(const Name &name, size_t prefixLen)
computes hash value of name.getPrefix(prefixLen)
provides options for Hashtable
const Node * find(const Name &name, size_t prefixLen) const
find node for name.getPrefix(prefixLen)
std::vector< HashValue > HashSequence
a sequence of hash values
float shrinkLoadFactor
if hashtable has less than nBuckets*shrinkLoadFactor nodes, it will be shrunk
a hashtable for fast exact name lookup
~Hashtable()
deallocates all nodes
Copyright (c) 2011-2015 Regents of the University of California.
Represents an absolute name.
Node * getNode(const Entry &entry)
size_t initialSize
initial number of buckets
Hashtable(const Options &options)
float shrinkFactor
when hashtable is shrunk, its new size is max(nBuckets*shrinkFactor, minSize)
size_t minSize
minimal number of buckets
an entry in the name tree
void erase(Node *node)
delete node