|
Boost-Commit : |
From: chintanraoh_at_[hidden]
Date: 2008-06-09 13:18:02
Author: chintanraoh
Date: 2008-06-09 13:18:01 EDT (Mon, 09 Jun 2008)
New Revision: 46279
URL: http://svn.boost.org/trac/boost/changeset/46279
Log:
get_key function
Text files modified:
sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/trie.hpp | 53 +++++++++++++++++++++++++++------------
1 files changed, 36 insertions(+), 17 deletions(-)
Modified: sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/trie.hpp
==============================================================================
--- sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/trie.hpp (original)
+++ sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/trie.hpp 2008-06-09 13:18:01 EDT (Mon, 09 Jun 2008)
@@ -54,14 +54,15 @@
new(node_root) node_type();
}
- trie(const type &other)
+ trie ( const type &other )
{
copy_trie_preserve(const_cast<node_type *>(other.node_root) );
}
- type &operator = ( const type other )
+ type &operator = ( const type &other )
{
if(node_root==other.node_root) return *this;
+
clear();
node_allocator.destroy(node_root);
node_allocator.deallocate(node_root,1);
@@ -130,6 +131,22 @@
{
return lower_bound<const_iterator,const_cursor,const type*>(this,key);
}
+
+ //not very clean but works
+ Key get_key(const const_iterator &cit) const
+ {
+ typedef typename std::vector<const_cursor>::const_iterator cur_const_iterator;
+ std::vector<typename Key_traits::element_type> e_vector;
+ Key ret_key;
+ for(cur_const_iterator it=++cit.cur_st.begin();it!=cit.cur_st.end();it++)
+ e_vector.push_back((*it).get_element());
+ return Key_traits::get_key(e_vector.begin(),e_vector.end());
+ }
+
+ Key get_key(const const_reverse_iterator &crit) const
+ {
+ return get_key(crit.get_iterator());
+ }
void erase(const key_type &key)
{
@@ -303,14 +320,6 @@
iter.top().get_node()->erase(node_it);
}
- void erase(iterator first, iterator second)
- {
- while(first!=second)
- {
- erase(first);
- ++first;
- }
- }
void swap(type &other)
{
@@ -338,16 +347,26 @@
return const_iterator(root(),true);
}
- reverse_iterator rbegin() const
+ reverse_iterator rbegin()
{
return reverse_iterator(begin(),end(),true);
}
- reverse_iterator rend() const
+ const_reverse_iterator rbegin() const
+ {
+ return const_reverse_iterator(begin(),end(),true);
+ }
+
+ reverse_iterator rend()
{
return reverse_iterator(begin(),end(),false);
}
+ const_reverse_iterator rend() const
+ {
+ return const_reverse_iterator(begin(),end(),false);
+ }
+
cursor root()
{
return cursor(node_root);
@@ -418,7 +437,7 @@
return false;
}
- void copy_trie_preserve(node_type*other_root)
+ inline void copy_trie_preserve(node_type*other_root)
{
node_type *prev,*temp_node;
typedef typename node_type::iterator node_iterator;
@@ -462,7 +481,7 @@
}
template<class It_type,class Cur_type,class Trie_ptr>
- static It_type find(Trie_ptr this_ptr,const key_type &key)
+ static inline It_type find(Trie_ptr this_ptr,const key_type &key)
{
typename Key_traits::const_iterator it=Key_traits::begin(key),
end_it=Key_traits::end(key);
@@ -488,7 +507,7 @@
template<class It_type,class Cur_type,class Trie_ptr>
- static It_type upper_bound(Trie_ptr this_ptr,const key_type &key)
+ static inline It_type upper_bound(Trie_ptr this_ptr,const key_type &key)
{
typename Key_traits::const_iterator it=Key_traits::begin(key),
end_it=Key_traits::end(key);
@@ -539,7 +558,7 @@
}
template<class It_type,class Cur_type,class Trie_ptr>
- static It_type lower_bound(Trie_ptr this_ptr,const key_type &key)
+ static inline It_type lower_bound(Trie_ptr this_ptr,const key_type &key)
{
typename Key_traits::const_iterator it=Key_traits::begin(key),
@@ -601,7 +620,7 @@
}
template<class Iter_type,class Cur_type,class Trie_t>
- static std::pair<Iter_type,Iter_type> prefix_range(Trie_t this_ptr,const key_type &key)
+ static inline std::pair<Iter_type,Iter_type> prefix_range(Trie_t this_ptr,const key_type &key)
{
typename Key_traits::const_iterator it=Key_traits::begin(key),
end_it=Key_traits::end(key);
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