Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2015 Regents of the University of California. |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and |
| 6 | * contributors. |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 60a7b62 | 2014-12-20 17:04:07 -0800 | [diff] [blame] | 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | **/ |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 19 | |
| 20 | #ifndef TRIE_WITH_POLICY_H_ |
| 21 | #define TRIE_WITH_POLICY_H_ |
| 22 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 23 | /// @cond include_hidden |
| 24 | |
Alexander Afanasyev | 0c39537 | 2014-12-20 15:54:02 -0800 | [diff] [blame] | 25 | #include "trie.hpp" |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 27 | namespace ns3 { |
| 28 | namespace ndn { |
| 29 | namespace ndnSIM { |
Alexander Afanasyev | 30cb117 | 2012-07-06 10:47:39 -0700 | [diff] [blame] | 30 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 31 | template<typename FullKey, typename PayloadTraits, typename PolicyTraits> |
| 32 | class trie_with_policy { |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 33 | public: |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 34 | typedef trie<FullKey, PayloadTraits, typename PolicyTraits::policy_hook_type> parent_trie; |
Alexander Afanasyev | 9e96e36 | 2012-07-02 23:04:39 -0700 | [diff] [blame] | 35 | |
| 36 | typedef typename parent_trie::iterator iterator; |
Alexander Afanasyev | 1ba09b8 | 2012-07-09 09:16:14 -0700 | [diff] [blame] | 37 | typedef typename parent_trie::const_iterator const_iterator; |
Alexander Afanasyev | 9e96e36 | 2012-07-02 23:04:39 -0700 | [diff] [blame] | 38 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 39 | typedef typename PolicyTraits:: |
| 40 | template policy<trie_with_policy<FullKey, PayloadTraits, PolicyTraits>, parent_trie, |
| 41 | typename PolicyTraits::template container_hook<parent_trie>::type>::type |
| 42 | policy_container; |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 43 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 44 | inline trie_with_policy(size_t bucketSize = 1, size_t bucketIncrement = 1) |
| 45 | : trie_(name::Component(), bucketSize, bucketIncrement) |
| 46 | , policy_(*this) |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 47 | { |
| 48 | } |
| 49 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 50 | inline std::pair<iterator, bool> |
| 51 | insert(const FullKey& key, typename PayloadTraits::insert_type payload) |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 52 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 53 | std::pair<iterator, bool> item = trie_.insert(key, payload); |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 54 | |
| 55 | if (item.second) // real insert |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 56 | { |
| 57 | bool ok = policy_.insert(s_iterator_to(item.first)); |
| 58 | if (!ok) { |
| 59 | item.first->erase(); // cannot insert |
| 60 | return std::make_pair(end(), false); |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 61 | } |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 62 | } |
| 63 | else { |
| 64 | return std::make_pair(s_iterator_to(item.first), false); |
| 65 | } |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 66 | |
| 67 | return item; |
| 68 | } |
| 69 | |
| 70 | inline void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 71 | erase(const FullKey& key) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 72 | { |
| 73 | iterator foundItem, lastItem; |
| 74 | bool reachLast; |
Alexander Afanasyev | 0717901 | 2014-12-21 00:23:04 -0800 | [diff] [blame] | 75 | std::tie(foundItem, reachLast, lastItem) = trie_.find(key); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 76 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 77 | if (!reachLast || lastItem->payload() == PayloadTraits::empty_payload) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 78 | return; // nothing to invalidate |
| 79 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 80 | erase(lastItem); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | inline void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 84 | erase(iterator node) |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 85 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 86 | if (node == end()) |
| 87 | return; |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 88 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 89 | policy_.erase(s_iterator_to(node)); |
| 90 | node->erase(); // will do cleanup here |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 93 | inline void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 94 | clear() |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 95 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 96 | policy_.clear(); |
| 97 | trie_.clear(); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | template<typename Modifier> |
| 101 | bool |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 102 | modify(iterator position, Modifier mod) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 103 | { |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 104 | if (position == end()) |
| 105 | return false; |
| 106 | if (position->payload() == PayloadTraits::empty_payload) |
| 107 | return false; |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 108 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 109 | mod(*position->payload()); |
| 110 | policy_.update(position); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 111 | return true; |
| 112 | } |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * @brief Find a node that has the exact match with the key |
| 116 | */ |
| 117 | inline iterator |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 118 | find_exact(const FullKey& key) |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 119 | { |
| 120 | iterator foundItem, lastItem; |
| 121 | bool reachLast; |
Alexander Afanasyev | 0717901 | 2014-12-21 00:23:04 -0800 | [diff] [blame] | 122 | std::tie(foundItem, reachLast, lastItem) = trie_.find(key); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 123 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 124 | if (!reachLast || lastItem->payload() == PayloadTraits::empty_payload) |
| 125 | return end(); |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 126 | |
| 127 | return lastItem; |
| 128 | } |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 129 | |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 130 | /** |
| 131 | * @brief Find a node that has the longest common prefix with key (FIB/PIT lookup) |
| 132 | */ |
| 133 | inline iterator |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 134 | longest_prefix_match(const FullKey& key) |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 135 | { |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 136 | iterator foundItem, lastItem; |
| 137 | bool reachLast; |
Alexander Afanasyev | 0717901 | 2014-12-21 00:23:04 -0800 | [diff] [blame] | 138 | std::tie(foundItem, reachLast, lastItem) = trie_.find(key); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 139 | if (foundItem != trie_.end()) { |
| 140 | policy_.lookup(s_iterator_to(foundItem)); |
| 141 | } |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 142 | return foundItem; |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 145 | /** |
| 146 | * @brief Find a node that has the longest common prefix with key (FIB/PIT lookup) |
| 147 | */ |
| 148 | template<class Predicate> |
| 149 | inline iterator |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 150 | longest_prefix_match_if(const FullKey& key, Predicate pred) |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 151 | { |
| 152 | iterator foundItem, lastItem; |
| 153 | bool reachLast; |
Alexander Afanasyev | 0717901 | 2014-12-21 00:23:04 -0800 | [diff] [blame] | 154 | std::tie(foundItem, reachLast, lastItem) = trie_.find_if(key, pred); |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 155 | if (foundItem != trie_.end()) { |
| 156 | policy_.lookup(s_iterator_to(foundItem)); |
| 157 | } |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 158 | return foundItem; |
| 159 | } |
| 160 | |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 161 | // /** |
| 162 | // * @brief Const version of the longest common prefix match |
| 163 | // * (semi-const, because there could be update of the policy anyways) |
| 164 | // */ |
| 165 | // inline const_iterator |
| 166 | // longest_prefix_match (const FullKey &key) const |
| 167 | // { |
| 168 | // return static_cast<trie_with_policy*> (this)->longest_prefix_match (key); |
| 169 | // } |
| 170 | |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 171 | /** |
| 172 | * @brief Find a node that has prefix at least as the key (cache lookup) |
| 173 | */ |
| 174 | inline iterator |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 175 | deepest_prefix_match(const FullKey& key) |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 176 | { |
| 177 | iterator foundItem, lastItem; |
| 178 | bool reachLast; |
Alexander Afanasyev | 0717901 | 2014-12-21 00:23:04 -0800 | [diff] [blame] | 179 | std::tie(foundItem, reachLast, lastItem) = trie_.find(key); |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 180 | |
| 181 | // guard in case we don't have anything in the trie |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 182 | if (lastItem == trie_.end()) |
| 183 | return trie_.end(); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 184 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 185 | if (reachLast) { |
| 186 | if (foundItem == trie_.end()) { |
| 187 | foundItem = lastItem->find(); // should be something |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 188 | } |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 189 | policy_.lookup(s_iterator_to(foundItem)); |
| 190 | return foundItem; |
| 191 | } |
| 192 | else { // couldn't find a node that has prefix at least as key |
| 193 | return trie_.end(); |
| 194 | } |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /** |
| 198 | * @brief Find a node that has prefix at least as the key |
| 199 | */ |
| 200 | template<class Predicate> |
| 201 | inline iterator |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 202 | deepest_prefix_match_if(const FullKey& key, Predicate pred) |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 203 | { |
| 204 | iterator foundItem, lastItem; |
| 205 | bool reachLast; |
Alexander Afanasyev | 0717901 | 2014-12-21 00:23:04 -0800 | [diff] [blame] | 206 | std::tie(foundItem, reachLast, lastItem) = trie_.find(key); |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 207 | |
| 208 | // guard in case we don't have anything in the trie |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 209 | if (lastItem == trie_.end()) |
| 210 | return trie_.end(); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 211 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 212 | if (reachLast) { |
| 213 | foundItem = lastItem->find_if(pred); // may or may not find something |
| 214 | if (foundItem == trie_.end()) { |
| 215 | return trie_.end(); |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 216 | } |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 217 | policy_.lookup(s_iterator_to(foundItem)); |
| 218 | return foundItem; |
| 219 | } |
| 220 | else { // couldn't find a node that has prefix at least as key |
| 221 | return trie_.end(); |
| 222 | } |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 223 | } |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 224 | |
Alexander Afanasyev | eec89ba | 2013-07-19 16:34:30 -0700 | [diff] [blame] | 225 | /** |
| 226 | * @brief Find a node that has prefix at least as the key |
| 227 | * |
| 228 | * This version of find checks predicate for the next level and if |
| 229 | * predicate is True, returns first deepest match available |
| 230 | */ |
| 231 | template<class Predicate> |
| 232 | inline iterator |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 233 | deepest_prefix_match_if_next_level(const FullKey& key, Predicate pred) |
Alexander Afanasyev | eec89ba | 2013-07-19 16:34:30 -0700 | [diff] [blame] | 234 | { |
| 235 | iterator foundItem, lastItem; |
| 236 | bool reachLast; |
Alexander Afanasyev | 0717901 | 2014-12-21 00:23:04 -0800 | [diff] [blame] | 237 | std::tie(foundItem, reachLast, lastItem) = trie_.find(key); |
Alexander Afanasyev | eec89ba | 2013-07-19 16:34:30 -0700 | [diff] [blame] | 238 | |
| 239 | // guard in case we don't have anything in the trie |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 240 | if (lastItem == trie_.end()) |
| 241 | return trie_.end(); |
Alexander Afanasyev | eec89ba | 2013-07-19 16:34:30 -0700 | [diff] [blame] | 242 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 243 | if (reachLast) { |
| 244 | foundItem = lastItem->find_if_next_level(pred); // may or may not find something |
| 245 | if (foundItem == trie_.end()) { |
| 246 | return trie_.end(); |
Alexander Afanasyev | eec89ba | 2013-07-19 16:34:30 -0700 | [diff] [blame] | 247 | } |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 248 | policy_.lookup(s_iterator_to(foundItem)); |
| 249 | return foundItem; |
| 250 | } |
| 251 | else { // couldn't find a node that has prefix at least as key |
| 252 | return trie_.end(); |
| 253 | } |
Alexander Afanasyev | eec89ba | 2013-07-19 16:34:30 -0700 | [diff] [blame] | 254 | } |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 255 | |
| 256 | iterator |
| 257 | end() const |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 258 | { |
| 259 | return 0; |
| 260 | } |
| 261 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 262 | const parent_trie& |
| 263 | getTrie() const |
| 264 | { |
| 265 | return trie_; |
| 266 | } |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 267 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 268 | parent_trie& |
| 269 | getTrie() |
| 270 | { |
| 271 | return trie_; |
| 272 | } |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 273 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 274 | const policy_container& |
| 275 | getPolicy() const |
| 276 | { |
| 277 | return policy_; |
| 278 | } |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 279 | |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 280 | policy_container& |
| 281 | getPolicy() |
| 282 | { |
| 283 | return policy_; |
| 284 | } |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 285 | |
| 286 | static inline iterator |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 287 | s_iterator_to(typename parent_trie::iterator item) |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 288 | { |
| 289 | if (item == 0) |
| 290 | return 0; |
| 291 | else |
| 292 | return &(*item); |
| 293 | } |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 294 | |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 295 | private: |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 296 | parent_trie trie_; |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 297 | mutable policy_container policy_; |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 298 | }; |
| 299 | |
Alexander Afanasyev | 30cb117 | 2012-07-06 10:47:39 -0700 | [diff] [blame] | 300 | } // ndnSIM |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 301 | } // ndn |
Alexander Afanasyev | e77db79 | 2012-08-09 11:10:58 -0700 | [diff] [blame] | 302 | } // ns3 |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 303 | |
Spyridon Mastorakis | 460f57c | 2014-12-17 00:44:14 -0800 | [diff] [blame] | 304 | /// @endcond |
| 305 | |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 306 | #endif // TRIE_WITH_POLICY_H_ |