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