Boost logo

Boost-Commit :

From: chintanraoh_at_[hidden]
Date: 2008-06-02 15:14:37


Author: chintanraoh
Date: 2008-06-02 15:14:37 EDT (Mon, 02 Jun 2008)
New Revision: 46050
URL: http://svn.boost.org/trac/boost/changeset/46050

Log:
added find(element_type) to cursor method
Text files modified:
   sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/node_cursor.hpp | 203 ++++++++++++++++++++-------------------
   1 files changed, 102 insertions(+), 101 deletions(-)

Modified: sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/node_cursor.hpp
==============================================================================
--- sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/node_cursor.hpp (original)
+++ sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/node_cursor.hpp 2008-06-02 15:14:37 EDT (Mon, 02 Jun 2008)
@@ -4,7 +4,6 @@
 #include <boost/dsearch/from_tree/cursor_helpers.hpp> //namespace boost::tree
 #include<assert.h>
 
-
 namespace boost {
 namespace dsearch {
         using boost::tree::cursor_facade;
@@ -13,126 +12,128 @@
                                 forward_traversal_tag,
                                 bidirectional_traversal_tag>
 
+{
+ private:
+ typedef trie_cursor<Key,Mapped,Node> cursor;
+ typedef typename Node::element_type element_type;
+
+ friend class boost::iterator_core_access;
+ friend class boost::tree::cursor_core_access;
+ unsigned char only_root;
+ bool top;
+
+ Node *cur;
+ typedef typename Node::iterator node_iterator;
+ node_iterator pos;
+
+ public:
+ trie_cursor()// :only_root(0),cur(0),top(0) (gave warnings!?!)
         {
- private:
- typedef trie_cursor<Key,Mapped,Node> cursor;
-
- friend class boost::iterator_core_access;
- friend class boost::tree::cursor_core_access;
- unsigned char only_root;
- bool top;
-
- Node *cur;
- typedef typename Node::iterator node_iterator;
- node_iterator pos;
+ only_root=0;cur=0;top=0;
+ }
 
- public:
- trie_cursor()// :only_root(0),cur(0),top(0) (gave warnings!?!)
- {
- only_root=0;cur=0;top=0;
- }
+ trie_cursor(Node * const n_ptr): only_root(1) , top(false)
+ {
+ cur=n_ptr;
+ }
 
- trie_cursor(Node * const n_ptr): only_root(1) , top(false)
- {
- cur=n_ptr;
- }
+ trie_cursor(const Node * n_ptr,const node_iterator it): only_root(0), top(false)
+ {
+ cur=const_cast<Node *>(n_ptr);
+ pos=it;
+ }
 
- trie_cursor(const Node * n_ptr,const node_iterator it): only_root(0), top(false)
+ private:
+ bool equal(cursor const& other) const
+ {
+ if(top==other.top)
                 {
- cur=const_cast<Node *>(n_ptr);
- pos=it;
+ if(top) return true;
                 }
-
- private:
- bool equal(cursor const& other) const
+ else
+ return false;
+ if(only_root==other.only_root)
                 {
- if(top==other.top)
- {
- if(top) return true;
- }
- else
- return false;
-
- if(only_root==other.only_root)
- {
- if (only_root==1 || only_root==2)
- return true;
- assert(only_root==0);
- }
- else
- return false;
+ if (only_root==1 || only_root==2)
+ return true;
+ assert(only_root==0);
+ }
+ else
+ return false;
 
- if(cur==other.cur && pos==other.pos) return true;
+ if(cur==other.cur && pos==other.pos) return true;
                         return false;
- }
+ }
 
- cursor left() const
+ cursor left() const
+ {
+ if(top)
                 {
- if(top)
- {
- return cursor(cur);
- }
- if(only_root)
- return cursor(cur,cur->begin());
- return cursor(*pos,(*pos)->begin());
+ return cursor(cur);
                 }
+ if(only_root)
+ return cursor(cur,cur->begin());
+ return cursor(*pos,(*pos)->begin());
+ }
 
- cursor right() const
- {
- if(top)
- return (++cursor(cur));
- if(only_root)
- return cursor(cur,cur->end());
- return cursor(*pos,(*pos)->end());
- }
+ cursor right() const
+ {
+ if(top)
+ return (++cursor(cur));
+ if(only_root)
+ return cursor(cur,cur->end());
+ return cursor(*pos,(*pos)->end());
+ }
 
- void decrement()
- {
- if(only_root)
- only_root--;
- else
- pos--;
- }
+ void decrement()
+ {
+ if(only_root)
+ only_root--;
+ else
+ pos--;
+ }
                 
- bool empty_() const
- {
- if(only_root)
- return cur->empty();
- return (*pos)->empty();
- }
+ bool empty_() const
+ {
+ return get_node()->empty();
+ }
 
- Node &dereference() const
- {
- return *get_node();
- }
+ Node &dereference() const
+ {
+ return *get_node();
+ }
 
- Node *get_node() const
- {
- if(only_root)
- return cur;
- return *pos;
- }
+ Node *get_node() const
+ {
+ if(only_root)
+ return cur;
+ return *pos;
+ }
 
- void increment()
- {
- if(only_root)
- only_root++;
- else
- pos++;
- }
- public:
-
+ void increment()
+ {
+ if(only_root)
+ only_root++;
+ else
+ pos++;
+ }
 
- bool has_value() const
- {
- return get_node()->has_value();
- }
+ public:
+ bool has_value() const
+ {
+ return get_node()->has_value();
+ }
 
- Mapped &get_value() const
- {
- return get_node()->get_value_ref();
- }
- };
+ Mapped &get_value() const
+ {
+ return get_node()->get_value_ref();
+ }
+
+ cursor find(const element_type &e)
+ {
+ return cursor(get_node(),get_node()->find(e));
+ }
+};
 }
 }
 


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