STK++ 0.9.13
STK_SparseIteratorBase.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_ITERATORBASE_H
37#define STK_ITERATORBASE_H
38
39#include <Sdk.h>
40
41namespace STK
42{
43namespace hidden
44{
69template <typename Derived> struct IteratorTraits;
70
71} // namespace hidden
72
79template<class Derived>
81{
82 private:
85
87
93
94 protected:
95
106
107 public:
109 int pos() const { return pos_;}
110
111 // moving
113 Derived& operator++() { ++pos_; return this->asDerived(); }
115 Derived& operator++(int junk) { ++pos_; return this->asDerived(); }
117 Derived& operator--() { --pos_; return this->asDerived(); }
119 Derived& operator--(int) { --pos_; return this->asDerived(); }
120
121 Derived& operator+=(int n) { pos_+=n; return this->asDerived(); }
122 Derived& operator-=(int n) { pos_-=n; return this->asDerived(); }
124 { SparseIteratorBase r(it); r+=n ; return r; }
126 { SparseIteratorBase r(it); r+=n ; return r; }
128 { SparseIteratorBase r(it); r-=n ; return r; }
130 { SparseIteratorBase r(it); r-=n ; return r; }
131
134
135 // comparing
137 bool operator==( SparseIteratorBase const& rhs) { return(pos_ ==rhs.pos_); }
139 bool operator!=( SparseIteratorBase const& rhs) { return(pos_!=rhs.pos_); }
140
142 friend bool operator<(SparseIteratorBase const& lhs, SparseIteratorBase const& rhs)
143 { return lhs.pos_ < rhs.pos_; };
145 friend bool operator>(SparseIteratorBase const& lhs, SparseIteratorBase const& rhs)
146 { return lhs.pos_ > rhs.pos_; };
148 friend bool operator<=(SparseIteratorBase const& lhs, SparseIteratorBase const& rhs)
149 { return lhs.pos_ <= rhs.pos_; };
151 friend bool operator>=(SparseIteratorBase const& lhs, SparseIteratorBase const& rhs)
152 { return lhs.pos_ >= rhs.pos_; };
153
156 { std::swap(lhs.pos_, rhs.pos_);}
157
158 protected:
161};
162
163
164} // namespace STK
165
166#endif /* STK_ITERATORBASE_H */
This file include all the other header files of the project Sdk.
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...
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 SparseIteratorBase operator+(int n, SparseIteratorBase const &it)
friend bool operator<(SparseIteratorBase const &lhs, SparseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
Index & pos_
Current position.
friend SparseIteratorBase operator-(SparseIteratorBase const &it, int n)
friend bool operator>(SparseIteratorBase const &lhs, SparseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
hidden::IteratorTraits< Derived >::pointer pointer
Derived & operator++()
next position
hidden::IteratorTraits< Derived >::iterator_category iterator_category
hidden::IteratorTraits< Derived >::Index Index
bool operator==(SparseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
friend SparseIteratorBase operator-(int n, SparseIteratorBase const &it)
SparseIteratorBase(Index &pos)
constructor with specified position
Derived & operator--()
previous position
friend SparseIteratorBase operator+(SparseIteratorBase const &it, int n)
friend bool operator<=(SparseIteratorBase const &lhs, SparseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
Derived & operator++(int junk)
next position
hidden::IteratorTraits< Derived >::reference reference
SparseIteratorBase()
default constructor
SparseIteratorBase(SparseIteratorBase const &it)
copy constructor.
friend bool operator>=(SparseIteratorBase const &lhs, SparseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
Derived & operator--(int)
previous position
friend void swap(SparseIteratorBase &lhs, SparseIteratorBase &rhs)
swap two iterators (only position is swaped)
bool operator!=(SparseIteratorBase const &rhs)
comparing two iterators (only position is compared !)
hidden::IteratorTraits< Derived >::difference_type difference_type
hidden::IteratorTraits< Derived >::value_type value_type
friend difference_type operator-(SparseIteratorBase it1, SparseIteratorBase it2)