29 #include <boost/concept/assert.hpp>
30 #include <boost/concept_check.hpp>
31 #include <type_traits>
49 const Node* node =
nullptr;
50 Entry* parent =
nullptr;
52 for (
size_t prefixLen = 0; prefixLen <= name.size(); ++prefixLen) {
54 std::tie(node, isNew) = m_ht.
insert(name, prefixLen, hashes);
56 if (isNew && parent !=
nullptr) {
59 parent = &node->
entry;
70 BOOST_ASSERT(fibEntry.
getPrefix().empty());
82 BOOST_ASSERT(nte !=
nullptr);
85 [&pitEntry] (
const shared_ptr<pit::Entry>& pitEntry1) {
86 return pitEntry1.get() == &pitEntry;
95 BOOST_ASSERT(pitEntry.
getName().at(-1).isImplicitSha256Digest());
104 BOOST_ASSERT(nte !=
nullptr);
114 BOOST_ASSERT(nte !=
nullptr);
123 BOOST_ASSERT(entry !=
nullptr);
126 for (
Entry* parent =
nullptr; entry !=
nullptr && entry->
isEmpty(); entry = parent) {
129 if (parent !=
nullptr) {
136 if (!canEraseAncestors) {
150 const Node* node = m_ht.
find(name, name.size());
151 return node ==
nullptr ?
nullptr : &node->
entry;
159 for (ssize_t prefixLen = name.size(); prefixLen >= 0; --prefixLen) {
160 const Node* node = m_ht.
find(name, prefixLen, hashes);
161 if (node !=
nullptr && entrySelector(node->
entry)) {
173 while (entry !=
nullptr) {
174 if (entrySelector(*entry)) {
182 template<
typename ENTRY>
187 BOOST_ASSERT(nte !=
nullptr);
206 BOOST_ASSERT(nte !=
nullptr);
211 BOOST_ASSERT(pitEntry.
getName().at(-1).isImplicitSha256Digest());
214 if (exact !=
nullptr) {
222 boost::iterator_range<NameTree::const_iterator>
232 return {
Iterator(make_shared<PrefixMatchImpl>(*
this, entrySelector), entry),
end()};
235 boost::iterator_range<NameTree::const_iterator>
238 return {
Iterator(make_shared<FullEnumerationImpl>(*
this, entrySelector),
nullptr),
end()};
241 boost::iterator_range<NameTree::const_iterator>
246 return {
Iterator(make_shared<PartialEnumerationImpl>(*
this, entrySubTreeSelector), entry),
end()};
void unsetParent()
unset parent of this entry
HashSequence computeHashes(const Name &name)
computes hash values for each prefix of name
Entry * findLongestPrefixMatch(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
longest prefix matching
represents a Measurements entry
size_t eraseIfEmpty(Entry *entry, bool canEraseAncestors=true)
delete the entry if it is empty
function< std::pair< bool, bool >const Entry &entry)> EntrySubTreeSelector
a predicate to accept or reject an Entry and its children
Range fullEnumerate(const EntrySelector &entrySelector=AnyEntry()) const
enumerate all entries
void setParent(Entry &entry)
set parent of this entry
strategy_choice::Entry * getStrategyChoiceEntry() const
Range partialEnumerate(const Name &prefix, const EntrySubTreeSelector &entrySubTreeSelector=AnyEntrySubTree()) const
enumerate all entries under a prefix
const std::vector< shared_ptr< pit::Entry > > & getPitEntries() const
Entry * getParent() const
fib::Entry * getFibEntry() const
const Name & getPrefix() const
provides options for Hashtable
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
std::pair< const Node *, bool > insert(const Name &name, size_t prefixLen, const HashSequence &hashes)
find or insert node for name.getPrefix(prefixLen)
Entry * findExactMatch(const Name &name) const
exact match lookup
std::vector< HashValue > HashSequence
a sequence of hash values
function< bool(const Entry &entry)> EntrySelector
a predicate to accept or reject an Entry in find operations
Range findAllMatches(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
all-prefixes match lookup
const Node * find(const Name &name, size_t prefixLen) const
find node for name.getPrefix(prefixLen)
Node * getNode(const Entry &entry)
an entry in the name tree
represents a Strategy Choice entry
measurements::Entry * getMeasurementsEntry() const
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
Entry & lookup(const Name &name)
find or insert an entry with specified name
void erase(Node *node)
delete node
const Name & getName() const
const Name & getName() const
Entry * getEntry(const ENTRY &tableEntry) const
NameTree(size_t nBuckets=1024)
const_iterator end() const