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 | ee5a444 | 2014-07-27 17:13:43 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014, Regents of the University of California, |
| 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 | |
| 29 | #include "common.hpp" |
| 30 | #include "name-tree-entry.hpp" |
| 31 | |
| 32 | namespace nfd { |
| 33 | namespace name_tree { |
| 34 | |
| 35 | /** |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 36 | * \brief Compute the hash value of the given name prefix's WIRE FORMAT |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 37 | */ |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 38 | size_t |
| 39 | computeHash(const Name& prefix); |
| 40 | |
| 41 | /** |
| 42 | * \brief Incrementally compute hash values |
| 43 | * \return Return a vector of hash values, starting from the root prefix |
| 44 | */ |
| 45 | std::vector<size_t> |
| 46 | computeHashSet(const Name& prefix); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 47 | |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 48 | /// a predicate to accept or reject an Entry in find operations |
| 49 | typedef function<bool (const Entry& entry)> EntrySelector; |
| 50 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 51 | /** |
| 52 | * \brief a predicate to accept or reject an Entry and its children |
| 53 | * \return .first indicates whether entry should be accepted; |
| 54 | * .second indicates whether entry's children should be visited |
| 55 | */ |
| 56 | typedef function<std::pair<bool,bool> (const Entry& entry)> EntrySubTreeSelector; |
| 57 | |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 58 | struct AnyEntry { |
| 59 | bool |
| 60 | operator()(const Entry& entry) |
| 61 | { |
| 62 | return true; |
| 63 | } |
| 64 | }; |
| 65 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 66 | struct AnyEntrySubTree { |
| 67 | std::pair<bool, bool> |
| 68 | operator()(const Entry& entry) |
| 69 | { |
| 70 | return std::make_pair(true, true); |
| 71 | } |
| 72 | }; |
| 73 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 74 | } // namespace name_tree |
| 75 | |
| 76 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 77 | * \brief Class Name Tree |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 78 | */ |
| 79 | class NameTree : noncopyable |
| 80 | { |
| 81 | public: |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 82 | class const_iterator; |
Junxiao Shi | 2b73ca3 | 2014-11-17 19:16:08 -0700 | [diff] [blame] | 83 | class Range; |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 84 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 85 | explicit |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 86 | NameTree(size_t nBuckets = 1024); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 87 | |
| 88 | ~NameTree(); |
| 89 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 90 | public: // information |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 91 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 92 | * \brief Get the number of occupied entries in the Name Tree |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 93 | */ |
| 94 | size_t |
| 95 | size() const; |
| 96 | |
| 97 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 98 | * \brief Get the number of buckets in the Name Tree (NPHT) |
| 99 | * \details The number of buckets is the one that used to create the hash |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 100 | * table, i.e., m_nBuckets. |
| 101 | */ |
| 102 | size_t |
| 103 | getNBuckets() const; |
| 104 | |
| 105 | /** |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 106 | * \brief Dump all the information stored in the Name Tree for debugging. |
| 107 | */ |
| 108 | void |
| 109 | dump(std::ostream& output) const; |
| 110 | |
| 111 | public: // mutation |
| 112 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 113 | * \brief Look for the Name Tree Entry that contains this name prefix. |
| 114 | * \details Starts from the shortest name prefix, and then increase the |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 115 | * number of name components by one each time. All non-existing Name Tree |
| 116 | * Entries will be created. |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 117 | * \param prefix The querying name prefix. |
| 118 | * \return The pointer to the Name Tree Entry that contains this full name |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 119 | * prefix. |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 120 | * \note Existing iterators are unaffected. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 121 | */ |
| 122 | shared_ptr<name_tree::Entry> |
| 123 | lookup(const Name& prefix); |
| 124 | |
| 125 | /** |
Junxiao Shi | ee5a444 | 2014-07-27 17:13:43 -0700 | [diff] [blame] | 126 | * \brief Delete a Name Tree Entry if this entry is empty. |
| 127 | * \param entry The entry to be deleted if empty. |
| 128 | * \note This function must be called after a table entry is detached from Name Tree |
| 129 | * entry. The function deletes a Name Tree entry if nothing is attached to it and |
| 130 | * it has no children, then repeats the same process on its ancestors. |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 131 | * \note Existing iterators, except those pointing to deleted entries, are unaffected. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 132 | */ |
| 133 | bool |
| 134 | eraseEntryIfEmpty(shared_ptr<name_tree::Entry> entry); |
| 135 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 136 | public: // shortcut access |
| 137 | /// get NameTree entry from attached FIB entry |
| 138 | shared_ptr<name_tree::Entry> |
| 139 | get(const fib::Entry& fibEntry) const; |
| 140 | |
| 141 | /// get NameTree entry from attached PIT entry |
| 142 | shared_ptr<name_tree::Entry> |
| 143 | get(const pit::Entry& pitEntry) const; |
| 144 | |
| 145 | /// get NameTree entry from attached Measurements entry |
| 146 | shared_ptr<name_tree::Entry> |
| 147 | get(const measurements::Entry& measurementsEntry) const; |
| 148 | |
| 149 | /// get NameTree entry from attached StrategyChoice entry |
| 150 | shared_ptr<name_tree::Entry> |
| 151 | get(const strategy_choice::Entry& strategyChoiceEntry) const; |
| 152 | |
| 153 | public: // matching |
| 154 | /** |
| 155 | * \brief Exact match lookup for the given name prefix. |
| 156 | * \return a null shared_ptr if this prefix is not found; |
| 157 | * otherwise return the Name Tree Entry address |
| 158 | */ |
| 159 | shared_ptr<name_tree::Entry> |
| 160 | findExactMatch(const Name& prefix) const; |
| 161 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 162 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 163 | * \brief Longest prefix matching for the given name |
| 164 | * \details Starts from the full name string, reduce the number of name component |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 165 | * by one each time, until an Entry is found. |
| 166 | */ |
| 167 | shared_ptr<name_tree::Entry> |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 168 | findLongestPrefixMatch(const Name& prefix, |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 169 | const name_tree::EntrySelector& entrySelector = |
| 170 | name_tree::AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 171 | |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 172 | shared_ptr<name_tree::Entry> |
| 173 | findLongestPrefixMatch(shared_ptr<name_tree::Entry> entry, |
| 174 | const name_tree::EntrySelector& entrySelector = |
| 175 | name_tree::AnyEntry()) const; |
| 176 | |
Junxiao Shi | 2b73ca3 | 2014-11-17 19:16:08 -0700 | [diff] [blame] | 177 | /** \brief Enumerate all the name prefixes that satisfy the prefix and entrySelector |
| 178 | * \return an unspecified type that have .begin() and .end() methods |
| 179 | * and is usable with range-based for |
| 180 | * |
| 181 | * Example: |
| 182 | * \code{.cpp} |
| 183 | * auto&& allMatches = nt.findAllMatches(Name("/A/B/C")); |
| 184 | * for (const name_tree::Entry& nte : allMatches) { |
| 185 | * ... |
| 186 | * } |
| 187 | * \endcode |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 188 | */ |
Junxiao Shi | 2b73ca3 | 2014-11-17 19:16:08 -0700 | [diff] [blame] | 189 | Range |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 190 | findAllMatches(const Name& prefix, |
| 191 | const name_tree::EntrySelector& entrySelector = name_tree::AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 192 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 193 | public: // enumeration |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 194 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 195 | * \brief Enumerate all the name prefixes stored in the Name Tree. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 196 | */ |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 197 | const_iterator |
| 198 | fullEnumerate(const name_tree::EntrySelector& entrySelector = name_tree::AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 199 | |
| 200 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 201 | * \brief Enumerate all the name prefixes that satisfies the EntrySubTreeSelector. |
| 202 | */ |
| 203 | const_iterator |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 204 | partialEnumerate(const Name& prefix, |
Junxiao Shi | efceadc | 2014-03-09 18:52:57 -0700 | [diff] [blame] | 205 | const name_tree::EntrySubTreeSelector& entrySubTreeSelector = |
| 206 | name_tree::AnyEntrySubTree()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 207 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 208 | const_iterator |
| 209 | begin() const; |
| 210 | |
| 211 | const_iterator |
| 212 | end() const; |
| 213 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 214 | enum IteratorType { |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 215 | FULL_ENUMERATE_TYPE, |
| 216 | PARTIAL_ENUMERATE_TYPE, |
| 217 | FIND_ALL_MATCHES_TYPE |
| 218 | }; |
| 219 | |
| 220 | class const_iterator : public std::iterator<std::forward_iterator_tag, name_tree::Entry> |
| 221 | { |
| 222 | public: |
| 223 | friend class NameTree; |
| 224 | |
| 225 | const_iterator(NameTree::IteratorType type, |
| 226 | const NameTree& nameTree, |
| 227 | shared_ptr<name_tree::Entry> entry, |
| 228 | const name_tree::EntrySelector& entrySelector = name_tree::AnyEntry(), |
| 229 | const name_tree::EntrySubTreeSelector& entrySubTreeSelector = name_tree::AnyEntrySubTree()); |
| 230 | |
| 231 | ~const_iterator(); |
| 232 | |
| 233 | const name_tree::Entry& |
| 234 | operator*() const; |
| 235 | |
| 236 | shared_ptr<name_tree::Entry> |
| 237 | operator->() const; |
| 238 | |
| 239 | const_iterator |
| 240 | operator++(); |
| 241 | |
| 242 | const_iterator |
| 243 | operator++(int); |
| 244 | |
| 245 | bool |
| 246 | operator==(const const_iterator& other) const; |
| 247 | |
| 248 | bool |
| 249 | operator!=(const const_iterator& other) const; |
| 250 | |
| 251 | private: |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 252 | const NameTree& m_nameTree; |
| 253 | shared_ptr<name_tree::Entry> m_entry; |
| 254 | shared_ptr<name_tree::Entry> m_subTreeRoot; |
| 255 | shared_ptr<name_tree::EntrySelector> m_entrySelector; |
| 256 | shared_ptr<name_tree::EntrySubTreeSelector> m_entrySubTreeSelector; |
| 257 | NameTree::IteratorType m_type; |
Junxiao Shi | efceadc | 2014-03-09 18:52:57 -0700 | [diff] [blame] | 258 | bool m_shouldVisitChildren; |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 259 | }; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 260 | |
Junxiao Shi | 2b73ca3 | 2014-11-17 19:16:08 -0700 | [diff] [blame] | 261 | /** \brief contains a pair of begin and end iterators |
| 262 | * |
| 263 | * This is to be used with range-based for. |
| 264 | */ |
| 265 | class Range |
| 266 | { |
| 267 | public: |
| 268 | Range(const_iterator begin, const_iterator end); |
| 269 | |
| 270 | const_iterator |
| 271 | begin() const |
| 272 | { |
| 273 | return m_begin; |
| 274 | } |
| 275 | |
| 276 | const_iterator |
| 277 | end() const |
| 278 | { |
| 279 | return m_end; |
| 280 | } |
| 281 | |
| 282 | private: |
| 283 | const_iterator m_begin; |
| 284 | const_iterator m_end; |
| 285 | }; |
| 286 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 287 | private: |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 288 | /** |
| 289 | * \brief Resize the hash table size when its load factor reaches a threshold. |
| 290 | * \details As we are currently using a hand-written hash table implementation |
| 291 | * for the Name Tree, the hash table resize() function should be kept in the |
| 292 | * name-tree.hpp file. |
| 293 | * \param newNBuckets The number of buckets for the new hash table. |
| 294 | */ |
| 295 | void |
| 296 | resize(size_t newNBuckets); |
| 297 | |
| 298 | private: |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 299 | size_t m_nItems; // Number of items being stored |
| 300 | size_t m_nBuckets; // Number of hash buckets |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 301 | size_t m_minNBuckets; // Minimum number of hash buckets |
| 302 | double m_enlargeLoadFactor; |
| 303 | size_t m_enlargeThreshold; |
| 304 | int m_enlargeFactor; |
| 305 | double m_shrinkLoadFactor; |
| 306 | size_t m_shrinkThreshold; |
| 307 | double m_shrinkFactor; |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 308 | name_tree::Node** m_buckets; // Name Tree Buckets in the NPHT |
| 309 | shared_ptr<name_tree::Entry> m_end; |
| 310 | const_iterator m_endIterator; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 311 | |
| 312 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 313 | * \brief Create a Name Tree Entry if it does not exist, or return the existing |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 314 | * Name Tree Entry address. |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 315 | * \details Called by lookup() only. |
| 316 | * \return The first item is the Name Tree Entry address, the second item is |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 317 | * a bool value indicates whether this is an old entry (false) or a new |
| 318 | * entry (true). |
| 319 | */ |
| 320 | std::pair<shared_ptr<name_tree::Entry>, bool> |
| 321 | insert(const Name& prefix); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 322 | }; |
| 323 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 324 | inline NameTree::const_iterator::~const_iterator() |
| 325 | { |
| 326 | } |
| 327 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 328 | inline size_t |
| 329 | NameTree::size() const |
| 330 | { |
| 331 | return m_nItems; |
| 332 | } |
| 333 | |
| 334 | inline size_t |
| 335 | NameTree::getNBuckets() const |
| 336 | { |
| 337 | return m_nBuckets; |
| 338 | } |
| 339 | |
Junxiao Shi | efceadc | 2014-03-09 18:52:57 -0700 | [diff] [blame] | 340 | inline shared_ptr<name_tree::Entry> |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 341 | NameTree::get(const fib::Entry& fibEntry) const |
| 342 | { |
| 343 | return fibEntry.m_nameTreeEntry; |
| 344 | } |
| 345 | |
| 346 | inline shared_ptr<name_tree::Entry> |
| 347 | NameTree::get(const pit::Entry& pitEntry) const |
| 348 | { |
| 349 | return pitEntry.m_nameTreeEntry; |
| 350 | } |
| 351 | |
| 352 | inline shared_ptr<name_tree::Entry> |
| 353 | NameTree::get(const measurements::Entry& measurementsEntry) const |
| 354 | { |
| 355 | return measurementsEntry.m_nameTreeEntry; |
| 356 | } |
| 357 | |
| 358 | inline shared_ptr<name_tree::Entry> |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 359 | NameTree::get(const strategy_choice::Entry& strategyChoiceEntry) const |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 360 | { |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 361 | return strategyChoiceEntry.m_nameTreeEntry; |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 362 | } |
| 363 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 364 | inline NameTree::const_iterator |
| 365 | NameTree::begin() const |
| 366 | { |
| 367 | return fullEnumerate(); |
| 368 | } |
| 369 | |
| 370 | inline NameTree::const_iterator |
| 371 | NameTree::end() const |
| 372 | { |
| 373 | return m_endIterator; |
| 374 | } |
| 375 | |
| 376 | inline const name_tree::Entry& |
| 377 | NameTree::const_iterator::operator*() const |
| 378 | { |
| 379 | return *m_entry; |
| 380 | } |
| 381 | |
| 382 | inline shared_ptr<name_tree::Entry> |
| 383 | NameTree::const_iterator::operator->() const |
| 384 | { |
| 385 | return m_entry; |
| 386 | } |
| 387 | |
| 388 | inline NameTree::const_iterator |
| 389 | NameTree::const_iterator::operator++(int) |
| 390 | { |
| 391 | NameTree::const_iterator temp(*this); |
| 392 | ++(*this); |
| 393 | return temp; |
| 394 | } |
| 395 | |
| 396 | inline bool |
| 397 | NameTree::const_iterator::operator==(const NameTree::const_iterator& other) const |
| 398 | { |
| 399 | return m_entry == other.m_entry; |
| 400 | } |
| 401 | |
| 402 | inline bool |
| 403 | NameTree::const_iterator::operator!=(const NameTree::const_iterator& other) const |
| 404 | { |
| 405 | return m_entry != other.m_entry; |
| 406 | } |
| 407 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 408 | } // namespace nfd |
| 409 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 410 | #endif // NFD_DAEMON_TABLE_NAME_TREE_HPP |