HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, Regents of the University of California, |
Alexander Afanasyev | 319f2c8 | 2015-01-07 14:56:53 -0800 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Junxiao Shi | ee5a444 | 2014-07-27 17:13:43 -0700 | [diff] [blame] | 24 | */ |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 25 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 26 | #ifndef NFD_DAEMON_TABLE_NAME_TREE_HPP |
| 27 | #define NFD_DAEMON_TABLE_NAME_TREE_HPP |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 28 | |
Junxiao Shi | 029401f | 2016-08-05 12:55:14 +0000 | [diff] [blame] | 29 | #include "name-tree-iterator.hpp" |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 30 | |
| 31 | namespace nfd { |
| 32 | namespace name_tree { |
| 33 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 34 | /** \brief a common index structure for FIB, PIT, StrategyChoice, and Measurements |
| 35 | */ |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 36 | class NameTree : noncopyable |
| 37 | { |
| 38 | public: |
Junxiao Shi | 029401f | 2016-08-05 12:55:14 +0000 | [diff] [blame] | 39 | typedef Iterator const_iterator; |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 40 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 41 | explicit |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 42 | NameTree(size_t nBuckets = 1024); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 43 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 44 | public: // information |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 45 | /** \return number of name tree entries |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 46 | */ |
| 47 | size_t |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 48 | size() const |
| 49 | { |
| 50 | return m_ht.size(); |
| 51 | } |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 52 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 53 | /** \return number of hashtable buckets |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 54 | */ |
| 55 | size_t |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 56 | getNBuckets() const |
| 57 | { |
| 58 | return m_ht.getNBuckets(); |
| 59 | } |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 60 | |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 61 | /** \return name tree entry on which a table entry is attached, |
| 62 | * or nullptr if the table entry is detached |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 63 | */ |
| 64 | template<typename ENTRY> |
Junxiao Shi | 7f35843 | 2016-08-11 17:06:33 +0000 | [diff] [blame] | 65 | Entry* |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 66 | getEntry(const ENTRY& tableEntry) const |
| 67 | { |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 68 | return Entry::get(tableEntry); |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 69 | } |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 70 | |
| 71 | public: // mutation |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 72 | /** \brief find or insert an entry with specified name |
| 73 | * \param name a name prefix |
| 74 | * \return an entry with \p name |
| 75 | * \post an entry with \p name and all ancestors are created |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 76 | * \note Existing iterators are unaffected. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 77 | */ |
Junxiao Shi | 7f35843 | 2016-08-11 17:06:33 +0000 | [diff] [blame] | 78 | Entry& |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 79 | lookup(const Name& name); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 80 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 81 | /** \brief equivalent to .lookup(fibEntry.getPrefix()) |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 82 | * \param fibEntry a FIB entry attached to this name tree, or Fib::s_emptyEntry |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 83 | * \note This overload is more efficient than .lookup(const Name&) in common cases. |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 84 | */ |
Junxiao Shi | 7f35843 | 2016-08-11 17:06:33 +0000 | [diff] [blame] | 85 | Entry& |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 86 | lookup(const fib::Entry& fibEntry); |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 87 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 88 | /** \brief equivalent to .lookup(pitEntry.getName()). |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 89 | * \param pitEntry a PIT entry attached to this name tree |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 90 | * \note This overload is more efficient than .lookup(const Name&) in common cases. |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 91 | */ |
Junxiao Shi | 7f35843 | 2016-08-11 17:06:33 +0000 | [diff] [blame] | 92 | Entry& |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 93 | lookup(const pit::Entry& pitEntry); |
| 94 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 95 | /** \brief equivalent to .lookup(measurementsEntry.getName()) |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 96 | * \param measurementsEntry a Measurements entry attached to this name tree |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 97 | * \note This overload is more efficient than .lookup(const Name&) in common cases. |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 98 | */ |
Junxiao Shi | 7f35843 | 2016-08-11 17:06:33 +0000 | [diff] [blame] | 99 | Entry& |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 100 | lookup(const measurements::Entry& measurementsEntry); |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 101 | |
Junxiao Shi | dd8f661 | 2016-08-12 15:42:52 +0000 | [diff] [blame] | 102 | /** \brief equivalent to .lookup(strategyChoiceEntry.getPrefix()) |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 103 | * \param strategyChoiceEntry a StrategyChoice entry attached to this name tree |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 104 | * \note This overload is more efficient than .lookup(const Name&) in common cases. |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 105 | */ |
Junxiao Shi | 7f35843 | 2016-08-11 17:06:33 +0000 | [diff] [blame] | 106 | Entry& |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 107 | lookup(const strategy_choice::Entry& strategyChoiceEntry); |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 108 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 109 | /** \brief delete the entry if it is empty |
| 110 | * \param entry a valid entry |
Junxiao Shi | e7258ff | 2016-08-12 23:55:47 +0000 | [diff] [blame] | 111 | * \param canEraseAncestors whether ancestors should be deleted if they become empty |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 112 | * \return number of deleted entries |
| 113 | * \sa Entry::isEmpty() |
Junxiao Shi | e7258ff | 2016-08-12 23:55:47 +0000 | [diff] [blame] | 114 | * \post If the entry is empty, it's deleted. If canEraseAncestors is true, |
| 115 | * ancestors of the entry are also deleted if they become empty. |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 116 | * \note This function must be called after detaching a table entry from a name tree entry, |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 117 | * \note Existing iterators, except those pointing to deleted entries, are unaffected. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 118 | */ |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 119 | size_t |
Junxiao Shi | e7258ff | 2016-08-12 23:55:47 +0000 | [diff] [blame] | 120 | eraseIfEmpty(Entry* entry, bool canEraseAncestors = true); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 121 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 122 | public: // matching |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 123 | /** \brief exact match lookup |
| 124 | * \return entry with \p name, or nullptr if it does not exist |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 125 | */ |
Junxiao Shi | 811c010 | 2016-08-10 04:12:45 +0000 | [diff] [blame] | 126 | Entry* |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 127 | findExactMatch(const Name& name) const; |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 128 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 129 | /** \brief longest prefix matching |
| 130 | * \return entry whose name is a prefix of \p name and passes \p entrySelector, |
| 131 | * where no other entry with a longer name satisfies those requirements; |
| 132 | * or nullptr if no entry satisfying those requirements exists |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 133 | */ |
Junxiao Shi | 811c010 | 2016-08-10 04:12:45 +0000 | [diff] [blame] | 134 | Entry* |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 135 | findLongestPrefixMatch(const Name& name, |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 136 | const EntrySelector& entrySelector = AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 137 | |
Junxiao Shi | 811c010 | 2016-08-10 04:12:45 +0000 | [diff] [blame] | 138 | /** \brief equivalent to .findLongestPrefixMatch(entry.getName(), entrySelector) |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 139 | * \note This overload is more efficient than |
| 140 | * .findLongestPrefixMatch(const Name&, const EntrySelector&) in common cases. |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 141 | */ |
Junxiao Shi | 811c010 | 2016-08-10 04:12:45 +0000 | [diff] [blame] | 142 | Entry* |
| 143 | findLongestPrefixMatch(const Entry& entry, |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 144 | const EntrySelector& entrySelector = AnyEntry()) const; |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 145 | |
Junxiao Shi | dd8f661 | 2016-08-12 15:42:52 +0000 | [diff] [blame] | 146 | /** \brief equivalent to .findLongestPrefixMatch(getEntry(tableEntry)->getName(), entrySelector) |
| 147 | * \tparam ENTRY fib::Entry or measurements::Entry or strategy_choice::Entry |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 148 | * \note This overload is more efficient than |
| 149 | * .findLongestPrefixMatch(const Name&, const EntrySelector&) in common cases. |
Junxiao Shi | dd8f661 | 2016-08-12 15:42:52 +0000 | [diff] [blame] | 150 | * \warning Undefined behavior may occur if tableEntry is not attached to this name tree. |
| 151 | */ |
| 152 | template<typename ENTRY> |
| 153 | Entry* |
| 154 | findLongestPrefixMatch(const ENTRY& tableEntry, |
| 155 | const EntrySelector& entrySelector = AnyEntry()) const; |
| 156 | |
| 157 | /** \brief equivalent to .findLongestPrefixMatch(pitEntry.getName(), entrySelector) |
| 158 | * \note This overload is more efficient than |
| 159 | * .findLongestPrefixMatch(const Name&, const EntrySelector&) in common cases. |
| 160 | * \warning Undefined behavior may occur if pitEntry is not attached to this name tree. |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 161 | */ |
Junxiao Shi | 811c010 | 2016-08-10 04:12:45 +0000 | [diff] [blame] | 162 | Entry* |
Junxiao Shi | f2420fc | 2016-08-11 13:18:21 +0000 | [diff] [blame] | 163 | findLongestPrefixMatch(const pit::Entry& pitEntry, |
| 164 | const EntrySelector& entrySelector = AnyEntry()) const; |
Junxiao Shi | 4370fde | 2016-02-24 12:20:46 -0700 | [diff] [blame] | 165 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 166 | /** \brief all-prefixes match lookup |
Junxiao Shi | 2b73ca3 | 2014-11-17 19:16:08 -0700 | [diff] [blame] | 167 | * \return an unspecified type that have .begin() and .end() methods |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 168 | * and is usable with range-based for. |
| 169 | * Every entry in the range has a name that is a prefix of \p name , |
| 170 | * and matches \p entrySelector. |
Junxiao Shi | 2b73ca3 | 2014-11-17 19:16:08 -0700 | [diff] [blame] | 171 | * |
| 172 | * Example: |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 173 | * \code |
| 174 | * Name name("/A/B/C"); |
| 175 | * auto&& allMatches = nt.findAllMatches(name); |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 176 | * for (const Entry& nte : allMatches) { |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 177 | * BOOST_ASSERT(nte.getName().isPrefixOf(name)); |
Junxiao Shi | 2b73ca3 | 2014-11-17 19:16:08 -0700 | [diff] [blame] | 178 | * ... |
| 179 | * } |
| 180 | * \endcode |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 181 | * \note Iteration order is implementation-specific and is undefined. |
| 182 | * \warning If a name tree entry whose name is a prefix of \p name is inserted |
| 183 | * during the enumeration, it may or may not be visited. |
| 184 | * If a name tree entry whose name is a prefix of \p name is deleted |
| 185 | * during the enumeration, undefined behavior may occur. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 186 | */ |
Junxiao Shi | 5ccd0c2 | 2014-12-02 23:54:42 -0700 | [diff] [blame] | 187 | boost::iterator_range<const_iterator> |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 188 | findAllMatches(const Name& name, |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 189 | const EntrySelector& entrySelector = AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 190 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 191 | public: // enumeration |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 192 | /** \brief enumerate all entries |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 193 | * \return an unspecified type that have .begin() and .end() methods |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 194 | * and is usable with range-based for. |
| 195 | * Every entry in the range matches \p entrySelector. |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 196 | * |
| 197 | * Example: |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 198 | * \code |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 199 | * auto&& enumerable = nt.fullEnumerate(); |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 200 | * for (const Entry& nte : enumerable) { |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 201 | * ... |
| 202 | * } |
| 203 | * \endcode |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 204 | * \note Iteration order is implementation-specific and is undefined. |
| 205 | * \warning If a name tree entry is inserted or deleted during the enumeration, |
| 206 | * it may cause the enumeration to skip entries or visit some entries twice. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 207 | */ |
Junxiao Shi | 5ccd0c2 | 2014-12-02 23:54:42 -0700 | [diff] [blame] | 208 | boost::iterator_range<const_iterator> |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 209 | fullEnumerate(const EntrySelector& entrySelector = AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 210 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 211 | /** \brief enumerate all entries under a prefix |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 212 | * \return an unspecified type that have .begin() and .end() methods |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 213 | * and is usable with range-based for. |
| 214 | * Every entry in the range has a name that starts with \p prefix, |
| 215 | * and matches \p entrySubTreeSelector. |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 216 | * |
| 217 | * Example: |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 218 | * \code |
| 219 | * Name name("/A/B/C"); |
| 220 | * auto&& enumerable = nt.partialEnumerate(name); |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 221 | * for (const Entry& nte : enumerable) { |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 222 | * BOOST_ASSERT(name.isPrefixOf(nte.getName())); |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 223 | * ... |
| 224 | * } |
| 225 | * \endcode |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 226 | * \note Iteration order is implementation-specific and is undefined. |
| 227 | * \warning If a name tree entry under \p prefix is inserted or deleted during the enumeration, |
| 228 | * it may cause the enumeration to skip entries or visit some entries twice. |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 229 | */ |
Junxiao Shi | 5ccd0c2 | 2014-12-02 23:54:42 -0700 | [diff] [blame] | 230 | boost::iterator_range<const_iterator> |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 231 | partialEnumerate(const Name& prefix, |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 232 | const EntrySubTreeSelector& entrySubTreeSelector = AnyEntrySubTree()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 233 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 234 | /** \return an iterator to enumerate all entries |
| 235 | * \sa fullEnumerate |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame] | 236 | */ |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 237 | const_iterator |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 238 | begin() const |
| 239 | { |
| 240 | return fullEnumerate().begin(); |
| 241 | } |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 242 | |
Junxiao Shi | e3cf285 | 2016-08-09 03:50:56 +0000 | [diff] [blame] | 243 | /** \return a past-the-end iterator |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame] | 244 | */ |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 245 | const_iterator |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 246 | end() const |
| 247 | { |
| 248 | return Iterator(); |
| 249 | } |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 250 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 251 | private: |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 252 | Hashtable m_ht; |
Junxiao Shi | b184e53 | 2016-05-26 18:09:57 +0000 | [diff] [blame] | 253 | |
Junxiao Shi | b660b4c | 2016-08-06 20:47:44 +0000 | [diff] [blame] | 254 | friend class EnumerationImpl; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 255 | }; |
| 256 | |
Junxiao Shi | 2570f3e | 2016-07-27 02:48:29 +0000 | [diff] [blame] | 257 | } // namespace name_tree |
| 258 | |
| 259 | using name_tree::NameTree; |
| 260 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 261 | } // namespace nfd |
| 262 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 263 | #endif // NFD_DAEMON_TABLE_NAME_TREE_HPP |