30 #include <boost/concept/assert.hpp> 31 #include <boost/concept_check.hpp> 32 #include <boost/range/concepts.hpp> 33 #include <type_traits> 38 BOOST_CONCEPT_ASSERT((boost::ForwardIterator<Iterator>));
39 static_assert(std::is_default_constructible<Iterator>::value,
40 "Iterator must be default-constructible");
42 BOOST_CONCEPT_ASSERT((boost::ForwardRangeConcept<Range>));
59 m_impl->advance(*
this);
66 BOOST_ASSERT(m_impl !=
nullptr);
67 m_impl->advance(*
this);
83 return m_entry == other.m_entry;
89 if (i.m_impl ==
nullptr) {
92 if (i.m_entry ==
nullptr) {
93 return os <<
"uninitialized";
96 os <<
"entry=" << i.m_entry->
getName();
97 if (i.m_ref ==
nullptr) {
101 os <<
" ref=" << i.m_ref->
getName();
103 os <<
" state=" << i.m_state;
123 if (i.m_entry ==
nullptr) {
124 for (
size_t bucket = 0; bucket <
ht.
getNBuckets(); ++bucket) {
126 if (node !=
nullptr) {
127 i.m_entry = &node->
entry;
131 if (i.m_entry ==
nullptr) {
135 if (m_pred(*i.m_entry)) {
142 if (m_pred(node->entry)) {
143 i.m_entry = &node->entry;
150 for (
size_t bucket = currentBucket + 1; bucket <
ht.
getNBuckets(); ++bucket) {
152 if (m_pred(node->entry)) {
153 i.m_entry = &node->entry;
172 bool wantSelf =
false;
173 bool wantChildren =
false;
176 if (i.m_entry ==
nullptr) {
177 if (i.m_ref ==
nullptr) {
183 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
185 i.m_state = wantChildren;
190 wantChildren =
static_cast<bool>(i.m_state);
192 BOOST_ASSERT(i.m_ref !=
nullptr);
195 while (i.m_entry != i.m_ref || (wantChildren && i.m_entry->
hasChildren())) {
198 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
200 i.m_state = wantChildren;
207 const std::vector<Entry*>& siblings = parent->
getChildren();
208 auto sibling = std::find(siblings.begin(), siblings.end(), i.m_entry);
209 BOOST_ASSERT(sibling != siblings.end());
210 while (++sibling != siblings.end()) {
211 i.m_entry = *sibling;
212 std::tie(wantSelf, wantChildren) = m_pred(*i.m_entry);
214 i.m_state = wantChildren;
222 if (sibling == siblings.end()) {
224 wantChildren =
false;
240 PrefixMatchImpl::advance(
Iterator& i)
242 if (i.m_entry ==
nullptr) {
243 if (i.m_ref ==
nullptr) {
249 if (m_pred(*i.m_entry)) {
255 while ((i.m_entry = i.m_entry->
getParent()) !=
nullptr) {
256 if (m_pred(*i.m_entry)) {
EnumerationImpl(const NameTree &nt)
size_t getNBuckets() const
bool operator==(const Iterator &other) const
function< std::pair< bool, bool >const Entry &entry)> EntrySubTreeSelector
a predicate to accept or reject an Entry and its children
const Node * getBucket(size_t bucket) const
virtual void advance(Iterator &i) override
size_t computeBucketIndex(HashValue h) const
FullEnumerationImpl(const NameTree &nt, const EntrySelector &pred)
const std::vector< Entry * > & getChildren() const
friend std::ostream & operator<<(std::ostream &, const Iterator &)
#define NFD_LOG_TRACE(expression)
Copyright (c) 2011-2015 Regents of the University of California.
function< bool(const Entry &entry)> EntrySelector
a predicate to accept or reject an Entry in find operations
PrefixMatchImpl(const NameTree &nt, const EntrySelector &pred)
Node * getNode(const Entry &entry)
a common index structure for FIB, PIT, StrategyChoice, and Measurements
Entry * getParent() const
#define NFD_LOG_INIT(name)
virtual void advance(Iterator &i) override
const Name & getName() const
enumeration operation implementation
an entry in the name tree
PartialEnumerationImpl(const NameTree &nt, const EntrySubTreeSelector &pred)