30 #include <boost/range/concepts.hpp> 36 BOOST_CONCEPT_ASSERT((boost::ForwardRangeConcept<Range>));
53 m_impl->advance(*
this);
60 BOOST_ASSERT(m_impl !=
nullptr);
61 m_impl->advance(*
this);
77 return m_entry == other.m_entry;
83 if (i.m_impl ==
nullptr) {
86 if (i.m_entry ==
nullptr) {
87 return os <<
"uninitialized";
90 os <<
"entry=" << i.m_entry->
getName();
91 if (i.m_ref ==
nullptr) {
95 os <<
" ref=" << i.m_ref->
getName();
97 os <<
" state=" << i.m_state;
117 if (i.m_entry ==
nullptr) {
118 for (
size_t bucket = 0; bucket <
ht.
getNBuckets(); ++bucket) {
120 if (node !=
nullptr) {
121 i.m_entry = &node->
entry;
125 if (i.m_entry ==
nullptr) {
129 if (m_pred(*i.m_entry)) {
136 if (m_pred(node->entry)) {
137 i.m_entry = &node->entry;
144 for (
size_t bucket = currentBucket + 1; bucket <
ht.
getNBuckets(); ++bucket) {
146 if (m_pred(node->entry)) {
147 i.m_entry = &node->entry;
166 bool wantSelf =
false;
167 bool wantChildren =
false;
170 if (i.m_entry ==
nullptr) {
171 if (i.m_ref ==
nullptr) {
177 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
179 i.m_state = wantChildren;
184 wantChildren =
static_cast<bool>(i.m_state);
186 BOOST_ASSERT(i.m_ref !=
nullptr);
189 while (i.m_entry != i.m_ref || (wantChildren && i.m_entry->
hasChildren())) {
192 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
194 i.m_state = wantChildren;
201 const std::vector<Entry*>& siblings = parent->
getChildren();
202 auto sibling = std::find(siblings.begin(), siblings.end(), i.m_entry);
203 BOOST_ASSERT(sibling != siblings.end());
204 while (++sibling != siblings.end()) {
205 i.m_entry = *sibling;
206 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
208 i.m_state = wantChildren;
216 if (sibling == siblings.end()) {
218 wantChildren =
false;
234 PrefixMatchImpl::advance(
Iterator& i)
236 if (i.m_entry ==
nullptr) {
237 if (i.m_ref ==
nullptr) {
243 if (m_pred(*i.m_entry)) {
249 while ((i.m_entry = i.m_entry->
getParent()) !=
nullptr) {
250 if (m_pred(*i.m_entry)) {
const std::vector< Entry * > & getChildren() const
a common index structure for FIB, PIT, StrategyChoice, and Measurements
NFD_ASSERT_FORWARD_ITERATOR(Iterator)
function< std::pair< bool, bool >const Entry &entry)> EntrySubTreeSelector
a predicate to accept or reject an Entry and its children
void advance(Iterator &i) override
bool operator==(const Iterator &other) const
Entry * getParent() const
enumeration operation implementation
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
EnumerationImpl(const NameTree &nt)
friend std::ostream & operator<<(std::ostream &, const Iterator &)
size_t computeBucketIndex(HashValue h) const
function< bool(const Entry &entry)> EntrySelector
a predicate to accept or reject an Entry in find operations
Node * getNode(const Entry &entry)
an entry in the name tree
PrefixMatchImpl(const NameTree &nt, const EntrySelector &pred)
#define NFD_LOG_INIT(name)
PartialEnumerationImpl(const NameTree &nt, const EntrySubTreeSelector &pred)
#define NFD_LOG_TRACE(expression)
size_t getNBuckets() const
void advance(Iterator &i) override
const Node * getBucket(size_t bucket) const
const Name & getName() const
FullEnumerationImpl(const NameTree &nt, const EntrySelector &pred)