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) {
152 return node ==
nullptr ? nullptr : &node->
entry;
160 for (ssize_t prefixLen =
name.size(); prefixLen >= 0; --prefixLen) {
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()};
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix of the name.
const Name & getPrefix() const
const std::vector< shared_ptr< pit::Entry > > & getPitEntries() const
const_iterator end() const
std::pair< const Node *, bool > insert(const Name &name, size_t prefixLen, const HashSequence &hashes)
find or insert node for name.getPrefix(prefixLen)
fib::Entry * getFibEntry() const
HashSequence computeHashes(const Name &name, size_t prefixLen)
computes hash values for each prefix of name.getPrefix(prefixLen)
function< std::pair< bool, bool >const Entry &entry)> EntrySubTreeSelector
a predicate to accept or reject an Entry and its children
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
void setParent(Entry &entry)
set parent of this entry
Entry * findLongestPrefixMatch(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
longest prefix matching
represents a Measurements entry
Range partialEnumerate(const Name &prefix, const EntrySubTreeSelector &entrySubTreeSelector=AnyEntrySubTree()) const
enumerate all entries under a prefix
const Component & at(ssize_t i) const
Get the component at the given index.
Range findAllMatches(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
all-prefixes match lookup
measurements::Entry * getMeasurementsEntry() const
#define NFD_LOG_TRACE(expression)
Copyright (c) 2011-2015 Regents of the University of California.
Entry & lookup(const Name &name, bool enforceMaxDepth=false)
find or insert an entry with specified name
Entry * getEntry(const EntryT &tableEntry) const
bool isImplicitSha256Digest() const
Check if the component is ImplicitSha256DigestComponent.
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
Range fullEnumerate(const EntrySelector &entrySelector=AnyEntry()) const
enumerate all entries
Node * getNode(const Entry &entry)
size_t size() const
Get number of components.
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.
void unsetParent()
unset parent of this entry
strategy_choice::Entry * getStrategyChoiceEntry() const
Entry * findExactMatch(const Name &name, size_t prefixLen=std::numeric_limits< size_t >::max()) const
exact match lookup
Entry * getParent() const
#define NFD_LOG_INIT(name)
const Name & getName() const
an entry in the name tree
void erase(Node *node)
delete node
static constexpr size_t getMaxDepth()
Maximum depth of the name tree.