37 : m_impl(std::move(impl))
40 m_impl->advance(*
this);
47 BOOST_ASSERT(m_impl !=
nullptr);
48 m_impl->advance(*
this);
56 if (i.m_impl ==
nullptr) {
59 if (i.m_entry ==
nullptr) {
60 return os <<
"uninitialized";
63 os <<
"entry=" << i.m_entry->
getName();
64 if (i.m_ref ==
nullptr) {
68 os <<
" ref=" << i.m_ref->
getName();
70 os <<
" state=" << i.m_state;
90 if (i.m_entry ==
nullptr) {
91 for (
size_t bucket = 0; bucket <
ht.
getNBuckets(); ++bucket) {
93 if (node !=
nullptr) {
94 i.m_entry = &node->
entry;
98 if (i.m_entry ==
nullptr) {
102 if (m_pred(*i.m_entry)) {
109 if (m_pred(node->entry)) {
110 i.m_entry = &node->entry;
117 for (
size_t bucket = currentBucket + 1; bucket <
ht.
getNBuckets(); ++bucket) {
119 if (m_pred(node->entry)) {
120 i.m_entry = &node->entry;
139 bool wantSelf =
false;
140 bool wantChildren =
false;
143 if (i.m_entry ==
nullptr) {
144 if (i.m_ref ==
nullptr) {
150 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
152 i.m_state = wantChildren;
157 wantChildren =
static_cast<bool>(i.m_state);
159 BOOST_ASSERT(i.m_ref !=
nullptr);
162 while (i.m_entry != i.m_ref || (wantChildren && i.m_entry->
hasChildren())) {
165 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
167 i.m_state = wantChildren;
174 const std::vector<Entry*>& siblings = parent->
getChildren();
175 auto sibling = std::find(siblings.begin(), siblings.end(), i.m_entry);
176 BOOST_ASSERT(sibling != siblings.end());
177 while (++sibling != siblings.end()) {
178 i.m_entry = *sibling;
179 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
181 i.m_state = wantChildren;
189 if (sibling == siblings.end()) {
191 wantChildren =
false;
207 PrefixMatchImpl::advance(
Iterator& i)
209 if (i.m_entry ==
nullptr) {
210 if (i.m_ref ==
nullptr) {
216 if (m_pred(*i.m_entry)) {
222 while ((i.m_entry = i.m_entry->
getParent()) !=
nullptr) {
223 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
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)
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.