29 #include <boost/concept/assert.hpp> 30 #include <boost/concept_check.hpp> 31 #include <type_traits> 47 BOOST_ASSERT(prefixLen <=
name.size());
51 const Node* node =
nullptr;
52 Entry* parent =
nullptr;
54 for (
size_t i = 0; i <= prefixLen; ++i) {
56 std::tie(node, isNew) = m_ht.
insert(
name, i, hashes);
58 if (isNew && parent !=
nullptr) {
61 parent = &node->
entry;
77 BOOST_ASSERT(nte->getFibEntry() == &fibEntry);
86 bool hasDigest =
name.size() > 0 &&
name[-1].isImplicitSha256Digest();
92 BOOST_ASSERT(nte !=
nullptr);
94 [&pitEntry] (
const shared_ptr<pit::Entry>& pitEntry1) {
95 return pitEntry1.get() == &pitEntry;
105 BOOST_ASSERT(nte !=
nullptr);
107 BOOST_ASSERT(nte->getMeasurementsEntry() == &measurementsEntry);
116 BOOST_ASSERT(nte !=
nullptr);
118 BOOST_ASSERT(nte->getStrategyChoiceEntry() == &strategyChoiceEntry);
125 BOOST_ASSERT(entry !=
nullptr);
128 for (
Entry* parent =
nullptr; entry !=
nullptr && entry->
isEmpty(); entry = parent) {
131 if (parent !=
nullptr) {
138 if (!canEraseAncestors) {
152 prefixLen = std::min(
name.size(), prefixLen);
158 return node ==
nullptr ? nullptr : &node->
entry;
167 for (ssize_t i = depth; i >= 0; --i) {
169 if (node !=
nullptr && entrySelector(node->
entry)) {
180 Entry* entry = const_cast<Entry*>(&entry1);
181 while (entry !=
nullptr) {
182 if (entrySelector(*entry)) {
194 BOOST_ASSERT(nte !=
nullptr);
200 for (
size_t i = nte->
getName().
size() + 1; i <= depth; ++i) {
202 if (exact ==
nullptr) {
212 boost::iterator_range<NameTree::const_iterator>
222 return {
Iterator(make_shared<PrefixMatchImpl>(*
this, entrySelector), entry),
end()};
225 boost::iterator_range<NameTree::const_iterator>
228 return {
Iterator(make_shared<FullEnumerationImpl>(*
this, entrySelector),
nullptr),
end()};
231 boost::iterator_range<NameTree::const_iterator>
236 return {
Iterator(make_shared<PartialEnumerationImpl>(*
this, entrySubTreeSelector), entry),
end()};
const Name & getName() const
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)
const Name & getPrefix() const
HashSequence computeHashes(const Name &name, size_t prefixLen)
computes hash values for each prefix 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
Entry & lookup(const Name &name, size_t prefixLen)
find or insert an entry by name
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
Range findAllMatches(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
all-prefixes match lookup
Copyright (c) 2011-2015 Regents of the University of California.
Entry * getEntry(const EntryT &tableEntry) const
Represents an absolute name.
represents a Strategy Choice entry
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
a common index structure for FIB, PIT, StrategyChoice, and Measurements
std::function< std::pair< bool, bool >(const Entry &)> EntrySubTreeSelector
a predicate to accept or reject an Entry and its children
const Name & getName() const
bool empty() const
Check if name is empty.
void unsetParent()
unset parent of this entry
Entry * findExactMatch(const Name &name, size_t prefixLen=std::numeric_limits< size_t >::max()) const
exact match lookup
Entry * getParent() const
std::function< bool(const Entry &)> EntrySelector
a predicate to accept or reject an Entry in find operations
#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