Boost logo

Boost-Commit :

From: chintanraoh_at_[hidden]
Date: 2008-08-07 11:50:38


Author: chintanraoh
Date: 2008-08-07 11:50:38 EDT (Thu, 07 Aug 2008)
New Revision: 48023
URL: http://svn.boost.org/trac/boost/changeset/48023

Log:
added extra key_traits for vectors
Text files modified:
   sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/pat_key_traits.hpp | 53 +++++++++++++++++++++++++++++++++++++++
   1 files changed, 52 insertions(+), 1 deletions(-)

Modified: sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/pat_key_traits.hpp
==============================================================================
--- sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/pat_key_traits.hpp (original)
+++ sandbox/SOC/2008/digital_searching/dsearch/boost/dsearch/pat_key_traits.hpp 2008-08-07 11:50:38 EDT (Thu, 07 Aug 2008)
@@ -2,13 +2,14 @@
 #define BOOST_DSEARCH_PAT_KEY_TRAITS_HPP
 
 #include<string>
+#include<vector>
 
 namespace boost{
 namespace dsearch{
 
 
 ///key traits describing extra traits required for patricia.
-class pat_key_traits{
+class pat_string_traits {
         public:
         /// element type = unsigned type. \n
         /// each element in string (ie char) should correspond to element_type.
@@ -60,6 +61,56 @@
         
 };
 
+template<typename type>
+class pat_vector_traits {
+ public:
+ /// element type = unsigned type. \n
+ typedef unsigned int element_type ;
+ /// Const_iterator used by patricia to iterate through elements.
+ /// It can be forward or random access.
+ typedef typename std::vector<type>::const_iterator const_iterator ;
+
+ /// Returns the begin iterator of a key.
+ /**
+ \returns const_iterator positioned at begining of the string.
+ \param key whose begin is to found
+ */
+ static inline const_iterator begin ( std::vector<type> const &key )
+ {
+ return key.begin();
+ }
+
+ /// Returns the end of a key.
+ /**
+ \returns const_iterator positioned at the end.
+ \param key whose end is to found
+ */
+ static inline const_iterator end (std::vector<type> const &key)
+ {
+ return key.end();
+ }
+
+ /// Returns the size of the key.
+ /**
+ \returns size of the key.
+ \param key whose size is to found
+ */
+ static inline std::size_t size(std::vector<type> const &key)
+ {
+ return key.size();
+ }
+
+ /// Deference iterator to corresponding element_type , ie unsigned type.
+ /**
+ \returns unsigned integer of element_type corresponding to the iterator.
+ \param it: iterator corresponding to which element_type if to be found
+ */
+ static inline element_type get_element(const const_iterator &it)
+ {
+ return static_cast<unsigned int>(*it);
+ }
+};
+
 }
 }
 


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