Alexander Afanasyev | fd0c41c | 2012-06-11 22:15:49 -0700 | [diff] [blame^] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2012 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #include "ns3/core-module.h" |
| 22 | #include "ns3/ndnSIM-module.h" |
| 23 | #include "../utils/trie.h" |
| 24 | |
| 25 | using namespace ns3; |
| 26 | |
| 27 | NS_LOG_COMPONENT_DEFINE ("Trie"); |
| 28 | |
| 29 | class Integer : public ns3::SimpleRefCount<Integer> |
| 30 | { |
| 31 | public: |
| 32 | Integer (int value) : value_ (value) {} |
| 33 | |
| 34 | private: |
| 35 | int value_; |
| 36 | }; |
| 37 | |
| 38 | int |
| 39 | main (int argc, char *argv[]) |
| 40 | { |
| 41 | trie<ns3::CcnxNameComponents, Integer, smart_pointer_payload_traits<Integer> > *x = |
| 42 | new trie<ns3::CcnxNameComponents, Integer, smart_pointer_payload_traits<Integer> >("root"); |
| 43 | |
| 44 | ns3::CcnxNameComponents n1,n2,n3,n5; |
| 45 | n1("a")("b")("c"); |
| 46 | n2("a")("c"); |
| 47 | n3("b")("c"); |
| 48 | n5("a")("b"); |
| 49 | |
| 50 | ns3::Ptr<Integer> i = ns3::Create<Integer> (1); |
| 51 | x->insert (n1, i); |
| 52 | x->insert (n2, i); |
| 53 | x->insert (n3, i); |
| 54 | x->insert (n5, i); |
| 55 | |
| 56 | ns3::CcnxNameComponents n4; |
| 57 | n4("a")("c"); |
| 58 | |
| 59 | // std::cout << *x->find (n4).get<0> (); |
| 60 | |
| 61 | x->prune (); |
| 62 | // x->find (n5).get<0> ()->erase (); |
| 63 | x->find (n1).get<0> ()->erase (); |
| 64 | |
| 65 | std::cout << "digraph trie {\n"; |
| 66 | std::cout << *x; |
| 67 | std::cout << "}\n"; |
| 68 | |
| 69 | delete x; |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |