STK++ 0.9.13
STK_DenseIteratorBase.h
Go to the documentation of this file.
1
2/*--------------------------------------------------------------------*/
3/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place,
19 Suite 330,
20 Boston, MA 02111-1307
21 USA
22
23 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
24*/
25
26/*
27 * Project: stkpp::Arrays
28 * created on: 28 marsh 2017
29 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
30 **/
31
36#ifndef STK_DENSEITERATORBASE_H
37#define STK_DENSEITERATORBASE_H
38
39namespace STK
40{
41namespace hidden
42{
67template <typename Derived> struct IteratorTraits;
68
69} // namespace hidden
70
77template<class Derived>
79{
81
87
88 protected:
101
102 public:
104 inline Index pos() const { return pos_;}
105
106 // moving
108 Derived& operator++() { ++pos_; return this->asDerived(); }
110 Derived& operator++(int junk) { ++pos_; return this->asDerived(); }
112 Derived& operator--() { --pos_; return this->asDerived(); }
114 Derived& operator--(int) { --pos_; return this->asDerived(); }
116 Derived& operator+=(Index n) { pos_+=n; return this->asDerived(); }
118 Derived& operator-=(Index n) { pos_-=n; return this->asDerived(); }
119
123 { DenseIteratorBase r(it); r+=n ; return r; }
126 { DenseIteratorBase r(it); r+=n ; return r; }
129 { DenseIteratorBase r(it); r-=n ; return r; }
131 { DenseIteratorBase r(it); r-=n ; return r; }
132
134 friend bool operator<(DenseIteratorBase const& lhs, DenseIteratorBase const& rhs)
135 { return lhs.pos_ < rhs.pos_; };
137 friend bool operator>(DenseIteratorBase const& lhs, DenseIteratorBase const& rhs)
138 { return lhs.pos_ > rhs.pos_; };
140 friend bool operator<=(DenseIteratorBase const& lhs, DenseIteratorBase const& rhs)
141 { return lhs.pos_ <= rhs.pos_; };
143 friend bool operator>=(DenseIteratorBase const& lhs, DenseIteratorBase const& rhs)
144 { return lhs.pos_ >= rhs.pos_; };
145
146 // misc
149 { std::swap(lhs.pos_, rhs.pos_);}
153
154
155 protected:
158};
159
160
161} // namespace STK
162
163#endif /* STK_DENSEITERATORBASE_H */
Interface base class for all classes implementing the curious recursive template paradigm.
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
const int baseIdx
base index of the containers created in STK++.
The namespace STK is the main domain space of the Statistical ToolKit project.
IteratorBase is a base class for all iterators on dense arrays/matrix/vector/expressions.
friend DenseIteratorBase operator-(DenseIteratorBase const &it, int n)
Subtract n positions to current position.
Derived & operator+=(Index n)
add n positions to current position
friend bool operator>(DenseIteratorBase const &lhs, DenseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
hidden::IteratorTraits< Derived >::Index Index
Derived & operator--(int)
previous position
hidden::IteratorTraits< Derived >::pointer pointer
friend DenseIteratorBase operator-(int n, DenseIteratorBase const &it)
friend DenseIteratorBase operator+(DenseIteratorBase const &it, int n)
add n positions to current position
hidden::IteratorTraits< Derived >::reference reference
Derived & operator++()
next position
friend bool operator<=(DenseIteratorBase const &lhs, DenseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
Derived & operator++(int junk)
next position
DenseIteratorBase()
default constructor
Index pos_
Current position.
DenseIteratorBase(DenseIteratorBase const &it)
copy constructor.
friend bool operator>=(DenseIteratorBase const &lhs, DenseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
Derived & operator--()
previous position
Derived & operator-=(Index n)
Subtract n positions to current position.
friend void swap(DenseIteratorBase &lhs, DenseIteratorBase &rhs)
swap two iterators (only position is swaped)
friend DenseIteratorBase operator+(int n, DenseIteratorBase const &it)
Subtract n positions to current position.
hidden::IteratorTraits< Derived >::value_type value_type
friend difference_type operator-(DenseIteratorBase it1, DenseIteratorBase it2)
difference of two positions
hidden::IteratorTraits< Derived >::iterator_category iterator_category
friend bool operator<(DenseIteratorBase const &lhs, DenseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
DenseIteratorBase(Index pos)
constructor with specified position
hidden::IteratorTraits< Derived >::difference_type difference_type