STK++ 0.9.13
STK_BiDirectionalIterator.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Arrays
27 * created on: 4 déc. 2015
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_BIDIRECTIONALITERATOR_H
36#define STK_BIDIRECTIONALITERATOR_H
37
39
40namespace STK
41{
42
43// forward declaration
44template<class Array> struct BiDirectionalIterator;
45template<class Array> struct ConstBiDirectionalIterator;
46
47namespace hidden
48{
52 template<class Array_>
82
86 template<class Array_>
116
117} // namespace hidden
118
119
126template<class Array>
127struct BiDirectionalIterator: public DenseIteratorBase< BiDirectionalIterator<Array> >
128 , public hidden::Traits< Array >::RowRange
129{
130 public:
133
134 enum
135 {
142 };
143
146
149
155
156 using Base::pos_;
157
158 // creating
161 {}
166 {
167 Base::operator =(it);
168 RowRange::operator =(it);
169 list1D_ = it.list1D_;
170 return *this;
171 }
172 // getting
174 pointer operator->() { return &(list1D_[pos_]); }
175 // misc
177 {
178 Base::swap(lhs, rhs);
179 std::swap(lhs.list1D_, rhs.list1D_);
180 }
181
182 private:
183 Array& list1D_;
184};
185
192template<class Array>
193struct ConstBiDirectionalIterator: public DenseIteratorBase< ConstBiDirectionalIterator<Array> >
194 , public hidden::Traits< Array >::RowRange
195{
196 public:
199
200 enum
201 {
208 };
209
212
215
221
222 using Base::pos_;
223
224 public:
225 // creating
227 : Base(pos)
228 , RowRange()
229 , list1D_(list1D)
230 {}
236 {
237 Base::operator=(it);
238 RowRange::operator=(it);
239 list1D_ = it.list1D_;
240 return *this;
241 }
242 // getting
244 pointer operator->() { return &(list1D_[pos_]); }
245 // misc
247 {
248 Base::swap(lhs, rhs);
249 std::swap(lhs.list1D_, rhs.list1D_);
250 }
251
252 private:
253 Array const& list1D_;
254};
255
256} // namespace STK
257
258#endif /* STK_BIDIRECTIONALITERATOR_H */
In this file we define the base class for Iterators on dense arrays.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
The namespace STK is the main domain space of the Statistical ToolKit project.
BiDirectionalIterator allows to loop over the element of one dimensional list containers.
DenseIteratorBase< BiDirectionalIterator > Base
BiDirectionalIterator(Array &list1D, int pos)
BiDirectionalIterator(BiDirectionalIterator const &it)
hidden::IteratorTraits< BiDirectionalIterator >::difference_type difference_type
hidden::IteratorTraits< BiDirectionalIterator >::ColRange ColRange
hidden::IteratorTraits< BiDirectionalIterator >::iterator_category iterator_category
hidden::IteratorTraits< BiDirectionalIterator >::reference reference
hidden::IteratorTraits< BiDirectionalIterator >::Index Index
hidden::IteratorTraits< BiDirectionalIterator >::value_type value_type
hidden::IteratorTraits< BiDirectionalIterator >::pointer pointer
hidden::IteratorTraits< BiDirectionalIterator >::RowRange RowRange
hidden::IteratorTraits< BiDirectionalIterator >::TypeConst TypeConst
friend void swap(BiDirectionalIterator &lhs, BiDirectionalIterator &rhs)
BiDirectionalIterator & operator=(BiDirectionalIterator const &it)
hidden::IteratorTraits< BiDirectionalIterator >::Type Type
ConstBiDirectionalIterator allows to loop over the element of one dimensional list containers.
hidden::IteratorTraits< ConstBiDirectionalIterator >::difference_type difference_type
hidden::IteratorTraits< ConstBiDirectionalIterator >::reference reference
hidden::IteratorTraits< ConstBiDirectionalIterator >::value_type value_type
hidden::IteratorTraits< ConstBiDirectionalIterator >::Type Type
ConstBiDirectionalIterator(Array const &list1D, int pos)
hidden::IteratorTraits< ConstBiDirectionalIterator >::iterator_category iterator_category
ConstBiDirectionalIterator & operator=(ConstBiDirectionalIterator const &it)
hidden::IteratorTraits< ConstBiDirectionalIterator >::ColRange ColRange
DenseIteratorBase< ConstBiDirectionalIterator > Base
ConstBiDirectionalIterator(ConstBiDirectionalIterator const &it)
hidden::IteratorTraits< ConstBiDirectionalIterator >::Index Index
hidden::IteratorTraits< ConstBiDirectionalIterator >::pointer pointer
friend void swap(ConstBiDirectionalIterator &lhs, ConstBiDirectionalIterator &rhs)
hidden::IteratorTraits< ConstBiDirectionalIterator >::TypeConst TypeConst
hidden::IteratorTraits< ConstBiDirectionalIterator >::RowRange RowRange
IteratorBase is a base class for all iterators on dense arrays/matrix/vector/expressions.
Index pos_
Current position.
friend void swap(DenseIteratorBase &lhs, DenseIteratorBase &rhs)
swap two iterators (only position is swaped)