Experimental trie implementation
diff --git a/examples/trie.cc b/examples/trie.cc
new file mode 100644
index 0000000..4a70a87
--- /dev/null
+++ b/examples/trie.cc
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ns3/core-module.h"
+#include "ns3/ndnSIM-module.h"
+#include "../utils/trie.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("Trie");
+
+class Integer : public ns3::SimpleRefCount<Integer>
+{
+public:
+ Integer (int value) : value_ (value) {}
+
+private:
+ int value_;
+};
+
+int
+main (int argc, char *argv[])
+{
+ trie<ns3::CcnxNameComponents, Integer, smart_pointer_payload_traits<Integer> > *x =
+ new trie<ns3::CcnxNameComponents, Integer, smart_pointer_payload_traits<Integer> >("root");
+
+ ns3::CcnxNameComponents n1,n2,n3,n5;
+ n1("a")("b")("c");
+ n2("a")("c");
+ n3("b")("c");
+ n5("a")("b");
+
+ ns3::Ptr<Integer> i = ns3::Create<Integer> (1);
+ x->insert (n1, i);
+ x->insert (n2, i);
+ x->insert (n3, i);
+ x->insert (n5, i);
+
+ ns3::CcnxNameComponents n4;
+ n4("a")("c");
+
+ // std::cout << *x->find (n4).get<0> ();
+
+ x->prune ();
+ // x->find (n5).get<0> ()->erase ();
+ x->find (n1).get<0> ()->erase ();
+
+ std::cout << "digraph trie {\n";
+ std::cout << *x;
+ std::cout << "}\n";
+
+ delete x;
+
+ return 0;
+}
+
diff --git a/examples/wscript b/examples/wscript
index 1b064a3..7a49ca3 100644
--- a/examples/wscript
+++ b/examples/wscript
@@ -1,8 +1,11 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
- obj = bld.create_ns3_program('ccnx-simple', ['NDNabstraction'])
+ obj = bld.create_ns3_program('ccnx-simple', ['ndnSIM'])
obj.source = 'ccnx-simple.cc'
- obj = bld.create_ns3_program('ccnx-grid', ['NDNabstraction', 'internet', 'point-to-point', 'point-to-point-layout'])
+ obj = bld.create_ns3_program('ccnx-grid', ['ndnSIM', 'point-to-point', 'point-to-point-layout'])
obj.source = 'ccnx-grid.cc'
+
+ obj = bld.create_ns3_program('trie', ['ndnSIM'])
+ obj.source = 'trie.cc'