30 #include <boost/range/concepts.hpp>
31 #include <ndn-cxx/util/concepts.hpp>
36 BOOST_CONCEPT_ASSERT((boost::ForwardRangeConcept<Range>));
43 : m_impl(std::move(impl))
46 m_impl->advance(*
this);
53 BOOST_ASSERT(m_impl !=
nullptr);
54 m_impl->advance(*
this);
70 return m_entry == other.m_entry;
76 if (i.m_impl ==
nullptr) {
79 if (i.m_entry ==
nullptr) {
80 return os <<
"uninitialized";
83 os <<
"entry=" << i.m_entry->
getName();
84 if (i.m_ref ==
nullptr) {
88 os <<
" ref=" << i.m_ref->
getName();
90 os <<
" state=" << i.m_state;
110 if (i.m_entry ==
nullptr) {
111 for (
size_t bucket = 0; bucket <
ht.
getNBuckets(); ++bucket) {
113 if (node !=
nullptr) {
114 i.m_entry = &node->
entry;
118 if (i.m_entry ==
nullptr) {
122 if (m_pred(*i.m_entry)) {
129 if (m_pred(node->entry)) {
130 i.m_entry = &node->entry;
137 for (
size_t bucket = currentBucket + 1; bucket <
ht.
getNBuckets(); ++bucket) {
139 if (m_pred(node->entry)) {
140 i.m_entry = &node->entry;
159 bool wantSelf =
false;
160 bool wantChildren =
false;
163 if (i.m_entry ==
nullptr) {
164 if (i.m_ref ==
nullptr) {
170 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
172 i.m_state = wantChildren;
177 wantChildren =
static_cast<bool>(i.m_state);
179 BOOST_ASSERT(i.m_ref !=
nullptr);
182 while (i.m_entry != i.m_ref || (wantChildren && i.m_entry->
hasChildren())) {
185 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
187 i.m_state = wantChildren;
194 const std::vector<Entry*>& siblings = parent->
getChildren();
195 auto sibling = std::find(siblings.begin(), siblings.end(), i.m_entry);
196 BOOST_ASSERT(sibling != siblings.end());
197 while (++sibling != siblings.end()) {
198 i.m_entry = *sibling;
199 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
201 i.m_state = wantChildren;
209 if (sibling == siblings.end()) {
211 wantChildren =
false;
227 PrefixMatchImpl::advance(
Iterator& i)
229 if (i.m_entry ==
nullptr) {
230 if (i.m_ref ==
nullptr) {
236 if (m_pred(*i.m_entry)) {
242 while ((i.m_entry = i.m_entry->
getParent()) !=
nullptr) {
243 if (m_pred(*i.m_entry)) {
An entry in the name tree.
Entry * getParent() const noexcept
const std::vector< Entry * > & getChildren() const noexcept
Returns the children of this entry.
bool hasChildren() const
Check whether this entry has any children.
const Name & getName() const noexcept
Enumeration operation implementation.
EnumerationImpl(const NameTree &nt)
FullEnumerationImpl(const NameTree &nt, const EntrySelector &pred)
void advance(Iterator &i) final
const Node * getBucket(size_t bucket) const
size_t computeBucketIndex(HashValue h) const
size_t getNBuckets() const
bool operator==(const Iterator &other) const
A common index structure for FIB, PIT, StrategyChoice, and Measurements.
PartialEnumerationImpl(const NameTree &nt, const EntrySubTreeSelector &pred)
void advance(Iterator &i) final
PrefixMatchImpl(const NameTree &nt, const EntrySelector &pred)
#define NFD_LOG_INIT(name)
std::ostream & operator<<(std::ostream &os, const Iterator &i)
NDN_CXX_ASSERT_FORWARD_ITERATOR(Iterator)
std::function< bool(const Entry &)> EntrySelector
A predicate to accept or reject an Entry in find operations.
Node * getNode(const Entry &entry)
std::function< std::pair< bool, bool >(const Entry &)> EntrySubTreeSelector
A predicate to accept or reject an Entry and its children.