29 #include <boost/concept/assert.hpp> 30 #include <boost/concept_check.hpp> 31 #include <type_traits> 50 const Node* node =
nullptr;
51 Entry* parent =
nullptr;
53 for (
size_t prefixLen = 0; prefixLen <= depth; ++prefixLen) {
55 std::tie(node, isNew) = m_ht.
insert(name, prefixLen, hashes);
57 if (isNew && parent !=
nullptr) {
60 parent = &node->
entry;
83 BOOST_ASSERT(nte !=
nullptr);
86 [&pitEntry] (
const shared_ptr<pit::Entry>& pitEntry1) {
87 return pitEntry1.get() == &pitEntry;
105 BOOST_ASSERT(nte !=
nullptr);
115 BOOST_ASSERT(nte !=
nullptr);
124 BOOST_ASSERT(entry !=
nullptr);
127 for (
Entry* parent =
nullptr; entry !=
nullptr && entry->
isEmpty(); entry = parent) {
130 if (parent !=
nullptr) {
137 if (!canEraseAncestors) {
151 const Node* node = m_ht.
find(name, std::min(name.
size(), prefixLen));
152 return node ==
nullptr ?
nullptr : &node->
entry;
160 for (ssize_t prefixLen = name.
size(); prefixLen >= 0; --prefixLen) {
161 const Node* node = m_ht.
find(name, prefixLen, hashes);
162 if (node !=
nullptr && entrySelector(node->
entry)) {
174 while (entry !=
nullptr) {
175 if (entrySelector(*entry)) {
187 BOOST_ASSERT(nte !=
nullptr);
193 if (exact ==
nullptr) {
203 boost::iterator_range<NameTree::const_iterator>
213 return {
Iterator(make_shared<PrefixMatchImpl>(*
this, entrySelector), entry),
end()};
216 boost::iterator_range<NameTree::const_iterator>
219 return {
Iterator(make_shared<FullEnumerationImpl>(*
this, entrySelector),
nullptr),
end()};
222 boost::iterator_range<NameTree::const_iterator>
227 return {
Iterator(make_shared<PartialEnumerationImpl>(*
this, entrySubTreeSelector), entry),
end()};
static size_t getMaxDepth()
Maximum depth of the name tree.
std::pair< const Node *, bool > insert(const Name &name, size_t prefixLen, const HashSequence &hashes)
find or insert node for name.getPrefix(prefixLen)
HashSequence computeHashes(const Name &name, size_t prefixLen)
computes hash values for each prefix of name.getPrefix(prefixLen)
const std::vector< shared_ptr< pit::Entry > > & getPitEntries() const
const Name & getName() const
function< std::pair< bool, bool >const Entry &entry)> EntrySubTreeSelector
a predicate to accept or reject an Entry and its children
provides options for Hashtable
std::vector< HashValue > HashSequence
a sequence of hash values
void setParent(Entry &entry)
set parent of this entry
Entry * getParent() const
strategy_choice::Entry * getStrategyChoiceEntry() const
represents a Measurements entry
#define NFD_LOG_TRACE(expression)
Entry * findExactMatch(const Name &name, size_t prefixLen=std::numeric_limits< size_t >::max()) const
exact match lookup
fib::Entry * getFibEntry() const
Copyright (c) 2011-2015 Regents of the University of California.
const_iterator end() const
Entry & lookup(const Name &name, bool enforceMaxDepth=false)
find or insert an entry with specified name
Range partialEnumerate(const Name &prefix, const EntrySubTreeSelector &entrySubTreeSelector=AnyEntrySubTree()) const
enumerate all entries under a prefix
Entry * getEntry(const EntryT &tableEntry) const
size_t size() const
Get number of components.
Represents an absolute name.
represents a Strategy Choice entry
function< bool(const Entry &entry)> EntrySelector
a predicate to accept or reject an Entry in find operations
const Component & at(ssize_t i) const
Get the component at the given index.
Node * getNode(const Entry &entry)
NameTree(size_t nBuckets=1024)
size_t eraseIfEmpty(Entry *entry, bool canEraseAncestors=true)
delete the entry if it is empty
const Name & getName() const
bool empty() const
Check if name is empty.
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix of the name.
measurements::Entry * getMeasurementsEntry() const
void unsetParent()
unset parent of this entry
Range fullEnumerate(const EntrySelector &entrySelector=AnyEntry()) const
enumerate all entries
#define NFD_LOG_INIT(name)
Range findAllMatches(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
all-prefixes match lookup
Entry * findLongestPrefixMatch(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
longest prefix matching
const Name & getPrefix() const
an entry in the name tree
bool isImplicitSha256Digest() const
Check if the component is ImplicitSha256DigestComponent.
void erase(Node *node)
delete node
const Node * find(const Name &name, size_t prefixLen) const
find node for name.getPrefix(prefixLen)