ivl 679
ivl/details/array/impl/specialization/row_elem_func_class_nd.hpp
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>.
00002    A C++ template library extending syntax towards mathematical notation.
00003 
00004    Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr>
00005    Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr>
00006 
00007    ivl is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU Lesser General Public License 
00009    version 3 as published by the Free Software Foundation.
00010 
00011    Alternatively, you can redistribute it and/or modify it under the terms 
00012    of the GNU General Public License version 2 as published by the Free 
00013    Software Foundation.
00014 
00015    ivl is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00018    See the GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License 
00021    and a copy of the GNU Lesser General Public License along 
00022    with ivl. If not, see <http://www.gnu.org/licenses/>. */
00023 
00024 #if 0
00025 //TODO: rewrite, correct and then include
00031 template <class T,
00032                  class F,
00033                  class A,
00034                  class DERIVED_INFO
00035              >
00036 class array<T, data::row_elem_func_nd<F, A>, DERIVED_INFO> :
00037 
00038 public array_common_base<array<T, data::row_elem_func_nd<F, A>, DERIVED_INFO> >
00039 {
00040 
00041 private:
00042         typedef array_common_base<array<T,
00043                 data::row_elem_func_nd<F, A>, DERIVED_INFO> > common_base_class;
00044 
00045 protected:
00046         const A* in;
00047 
00048 public:
00049 
00050         typedef data::row_elem_func_nd<F, A> data_type;
00051 
00052         typedef array <T, data_type, DERIVED_INFO> this_type;
00053 
00054         typedef this_type this_array_type;
00055 
00056         typedef this_type array_type;
00057 
00058         typedef T elem_type;
00059 
00060         typedef typename types::derive<this_type>::type derived_type;
00061 
00062         typedef typename common_base_class::base_class base_class;
00063 
00065         typedef size_t size_type;
00066 
00068         typedef ptrdiff_t diff_type;
00069 
00070         using base_class::derived;
00071 
00072         typedef typename array::has_random_access has_random_access;
00073 
00074 /*
00075         template<class ITER_1, class ITER_2>
00076         class const_iter
00077         {
00078         private:
00079                 typedef ITER_1 iter_1;
00080                 typedef ITER_2 iter_2;
00081 
00082                 iter_1 i1;
00083                 iter_2 i2;
00084 
00085                 typedef typename tool::template
00086                         rnd_it<const_iter<ITER_1, ITER_2> >::type rnd_iter;
00087 
00088         public:
00089 
00090                 // iterator_traits
00091                 typedef typename types::t_if<has_random_access,
00092                         std::random_access_iterator_tag,
00093                         std::bidirectional_iterator_tag>::type iterator_category;
00094 
00095                 typedef T value_type;
00096                 typedef ptrdiff_t difference_type;
00097                 typedef const T* pointer;
00098                 typedef const T& reference;
00099 
00100                 // constructors
00101                 const_iter() { }
00102 
00103                 const_iter(const iter_1& i1, const iter_2& i2) : i1(i1), i2(i2) { }
00104 
00105                 const_iter(const const_iter& it) : i1(it.i1), i2(it.i2) { }
00106 
00107                 // members
00108                 T operator *() const
00109                 {
00110                         return array_details::elem_func_swap_op<SWAP_ARGS,
00111                                 T, F<T, typename iter_1::value_type,
00112                                                 typename iter_2::value_type> >::
00113                                 from(*i1, *i2);
00114                 }
00115 
00116                 // optional random access in iterator
00117                 typename tool::brackets_ret_type operator[]
00118                         (typename tool::brackets_arg j) const
00119                 {
00120                         return array_details::elem_func_swap_op<SWAP_ARGS,
00121                                 T, F<T, typename iter_1::value_type,
00122                                                 typename iter_2::value_type> >::
00123                                 from(typename tool::brackets(i1, j),
00124                                         typename tool::brackets(i2, j));
00125                 }
00126 
00127                 // increment-decrement
00128                 const_iter& operator++()
00129                 {
00130                         ++i1;
00131                         ++i2;
00132                         return *this;
00133                 }
00134                 const_iter& operator--()
00135                 {
00136                         --i1;
00137                         --i2;
00138                         return *this;
00139                 }
00140 
00141                 const_iter operator++(int) { const_iter tmp(*this); ++(*this); return tmp; }
00142                 const_iter operator--(int) { const_iter tmp(*this); --(*this); return tmp; }
00143 
00144                 // random access. enabled only if 'has_random_access'
00145                 const_iter& operator +=(typename tool::brackets_arg j)
00146                 {
00147                         tool::add_asgn(i1, j);
00148                         tool::add_asgn(i2, j);
00149                         return *this;
00150                 }
00151                 const_iter& operator -=(typename tool::brackets_arg j)
00152                 {
00153                         tool::sub_asgn(i1, j);
00154                         tool::sub_asgn(i2, j);
00155                         return *this;
00156                 }
00157                 inline rnd_iter operator +(typename tool::brackets_arg j) const
00158                 {
00159                         return rnd_iter(tool::add_op(i1, j), tool::add_op(i2, j));
00160                 }
00161                 inline rnd_iter operator -(typename tool::brackets_arg j) const
00162                 {
00163                         return rnd_iter(tool::sub_op(i1, j), tool::sub_op(i2, j));
00164                 }
00165 
00166                 // difference
00167                 difference_type operator -(const rnd_iter& a) const
00168                 {
00169                         return tool::dif_op(*this, a);
00170                 }
00171 
00172                 //copy same type iterator
00173                 const_iter& operator=(const const_iter& o)
00174                 {
00175                         i1 = o.i1;
00176                         i2 = o.i2;
00177                         return *this;
00178                 }
00179 
00180                 bool operator==(const const_iter& o) const { return (i1 == o.i1); }
00181                 bool operator!=(const const_iter& o) const { return (i1 != o.i1); }
00182         };
00183 
00184         typedef const_iter<typename A1::const_iterator,
00185                 typename A2::const_iterator> const_iterator;
00186 
00187 CARE    typedef const_iter<typename A1::const_reverse_iterator,
00188                 typename A2::const_reverse_iterator> const_reverse_iterator;
00189 
00190         //added later
00191         typedef typename const_iterator::reference const_reference;
00192         typedef const_reference best_reference;
00193         typedef const_iterator best_iterator;
00194 
00195 
00196         const_iterator begin() const { return const_iterator(in1->begin(), in2->begin()); }
00197         const_iterator end() const { return const_iterator(in1->end(), in2->end()); }
00198 
00199         const_reverse_iterator rbegin() const { return const_reverse_iterator(in1->rbegin(), in2->rbegin()); }
00200         const_reverse_iterator rend() const { return const_reverse_iterator(in1->rend(), in2->rend()); }
00201 */
00202 #if 0
00203 
00205 
00206 
00207         size_t length(typename tool::brackets_arg
00208                 enable = typename tool::brackets_arg()) const
00209         {
00210                 return tool::len_op(in1->derived());
00211         }
00212 
00214         size_type size() const { return length(); }
00216         size_t numel() const { return length(); }
00225 
00226 
00227         T operator[](
00228                 typename tool::brackets_arg i) const
00229         {
00230                 CHECK(i >= 0 && i < length(), erange);
00231 
00232                 return array_details::elem_func_swap_op<SWAP_ARGS,
00233                         T, F<T, typename A1::elem_type, typename A2::elem_type> >::
00234                 from(tool::brackets(in1->derived(), i),
00235                         tool::brackets(in2->derived(), i));
00236         }
00242 
00243         array() { }
00244 
00246         array(const array& o)
00247                 { in1 = o.in1; in2 = o.in2; }
00248 
00250         void validate()
00251         {
00252                 CHECK(tool::len_valid(in1->derived(), in2->derived()), erange);
00253         }
00254 
00257 
00258         ~array() { }
00259 
00260 #endif
00261 };
00262 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations