seq_vector.h

00001 
00005 #pragma once
00006 
00007 #include <usml/ublas/ublas.h>
00008 
00009 namespace usml {
00010 namespace types {
00011 
00012 using namespace usml::ublas;
00013 
00016 
00026 class USML_DECLSPEC seq_vector: public vector_container<seq_vector>
00027 {
00028     public:
00029 
00030         typedef seq_vector self_type ;
00031         typedef double  value_type ;
00032         typedef value_type  reference ;
00033         typedef const reference const_reference ;
00034         typedef unbounded_array<value_type> array_type ;
00035         typedef array_type::size_type  size_type ;
00036         typedef array_type::difference_type  difference_type ;
00037         typedef dense_tag storage_category ;
00038         typedef indexed_const_iterator<self_type, dense_random_access_iterator_tag> const_iterator;
00039         typedef const_iterator  iterator ;
00040         typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
00041         typedef const vector_reference<const self_type> const_closure_type ;
00042         typedef vector_reference<self_type> closure_type ;
00043 
00047         virtual ~seq_vector() {}
00048 
00050         virtual self_type* clone() const = 0 ;
00051 
00063         virtual size_type find_index( value_type value ) = 0 ;
00064 
00073         const_reference operator[] ( size_type index ) const {
00074             return _data[index] ;
00075         }
00076 
00085         virtual const_reference operator () ( size_type index ) const {
00086             index = max( (size_type) 0, min(_max_index,index) ) ;
00087             return _data[index];
00088         }
00089 
00099         const_reference increment( size_type index ) const {
00100             index = std::max( (size_type)0, std::min(_max_index,index) ) ;
00101             return _increment[index] ;
00102         }
00103 
00107         size_type size() const {
00108             return _data.size() ;
00109         }
00110 
00114         array_type data() const {
00115             return _data ;
00116         }
00117 
00121         const_iterator begin() const {
00122             return find(0) ;
00123         }
00124 
00125         const_iterator end() const {
00126             return find( _data.size() ) ;
00127         }
00128 
00132         const_reverse_iterator rbegin() const {
00133             return const_reverse_iterator( end() ) ;
00134         }
00135 
00136         const_reverse_iterator rend() const {
00137             return const_reverse_iterator( begin() ) ;
00138         }
00139 
00143         const_iterator find( size_type i ) const {
00144             return const_iterator (*this, i);
00145         }
00146 
00147     protected:
00148 
00152         seq_vector( size_type size )
00153             : vector_container<self_type> (),
00154               _data(size), _increment(size),
00155               _max_index(size-1)
00156         {}
00157 
00163         seq_vector( const self_type& other )
00164             : vector_container<self_type> (),
00165               _data(other._data), _increment(other._increment),
00166               _max_index(other._max_index)
00167         {}
00168 
00172         array_type _data ;
00173 
00177         array_type _increment ;
00178 
00180         size_type _max_index ;
00181 
00182 }; // end of class
00183 
00185 } // end of namespace types
00186 } // end of namespace usml

Generated on 4 May 2015 for USML by  doxygen 1.6.1