Boost logo

Boost-Commit :

From: chintanraoh_at_[hidden]
Date: 2008-06-05 14:24:21


Author: chintanraoh
Date: 2008-06-05 14:24:20 EDT (Thu, 05 Jun 2008)
New Revision: 46175
URL: http://svn.boost.org/trac/boost/changeset/46175

Log:
added a copy constructor
Text files modified:
   sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/trie_array_node.hpp | 19 +++++++++++++++++--
   1 files changed, 17 insertions(+), 2 deletions(-)

Modified: sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/trie_array_node.hpp
==============================================================================
--- sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/trie_array_node.hpp (original)
+++ sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/trie_array_node.hpp 2008-06-05 14:24:20 EDT (Thu, 05 Jun 2008)
@@ -3,6 +3,7 @@
 
 #include<iostream>
 #include<string.h>
+#include<assert.h>
 #include<boost/iterator/iterator_facade.hpp>
 #include<memory>
 
@@ -66,7 +67,6 @@
         }
 };
 
-//TODO:write a copy constructor for good
 template<class Key,class Mapped,class Key_traits,class Alloc=std::allocator<char> >
 class trie_array_node
 {
@@ -82,6 +82,7 @@
         typedef trie_array_node_iterator<type> iterator;
         typedef element_type key_type;
         typedef type* value_type;
+
         bool value_indicator;
         Mapped value; //should it be mapped *? depending on sizeof(mapped)
 
@@ -97,6 +98,15 @@
                 memset(child_ptr,0,sizeof(child_ptr));
         }
 
+ trie_array_node(const type &other)
+ {
+ value_indicator=other.value_indicator;
+ value=other.value;
+ assert( memcpy(child_ptr, other.child_ptr, sizeof(child_ptr) ) == child_ptr) ;
+/* for(int i=0;i<max;i++)
+ child_ptr[i]=(type*)bool(child_ptr[i]);*/
+ }
+
         void insert(const element_type &key,type * const &child_cursor)
         {
                 child_ptr[Key_traits::get_value(key)]=child_cursor;
@@ -157,11 +167,16 @@
                 return t_size;
         }
 
+ element_type get_element(const iterator &it)
+ {
+ return Key_traits::get_element(it.pos);
+ }
+
         iterator lower_bound(const element_type &e)
         {
                 int k=Key_traits::get_value(e);
                 for(;k>=0;k--)
- if(child_ptr[k]!=0) break;
+ if(child_ptr[k]!=0) break;
                 if(k<0) return end();
                 return iterator(this,k);
         }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk