LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
ndarray
10.1+37
include
ndarray
detail
StridedIterator.h
Go to the documentation of this file.
1
// -*- c++ -*-
2
/*
3
* LSST Data Management System
4
* Copyright 2008, 2009, 2010, 2011 LSST Corporation.
5
*
6
* This product includes software developed by the
7
* LSST Project (http://www.lsst.org/).
8
*
9
* This program is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the LSST License Statement and
20
* the GNU General Public License along with this program. If not,
21
* see <http://www.lsstcorp.org/LegalNotices/>.
22
*/
23
#ifndef NDARRAY_DETAIL_StridedIterator_h_INCLUDED
24
#define NDARRAY_DETAIL_StridedIterator_h_INCLUDED
25
32
#include "
ndarray_fwd.h
"
33
#include <boost/iterator/iterator_facade.hpp>
34
35
namespace
ndarray {
36
namespace
detail {
37
43
template
<
typename
T>
44
class
StridedIterator
:
public
boost::iterator_facade<
45
StridedIterator<T>,
46
T, boost::random_access_traversal_tag
47
>
48
{
49
public
:
50
typedef
T
Value
;
51
typedef
T &
Reference
;
52
53
StridedIterator
() :
_data
(0),
_stride
(0) {}
54
55
StridedIterator
(T * data,
int
stride) :
_data
(data),
_stride
(stride) {}
56
57
StridedIterator
(
StridedIterator
const
& other) :
_data
(other.
_data
),
_stride
(other.
_stride
) {}
58
59
template
<
typename
U>
60
StridedIterator
(
StridedIterator<U>
const
& other) :
_data
(other.
_data
),
_stride
(other.
_stride
) {
61
BOOST_STATIC_ASSERT((boost::is_convertible<U*,T*>::value));
62
}
63
64
StridedIterator
&
operator=
(
StridedIterator
const
& other) {
65
if
(&other !=
this
) {
66
_data
= other.
_data
;
67
_stride
= other.
_stride
;
68
}
69
return
*
this
;
70
}
71
72
template
<
typename
U>
73
StridedIterator
&
operator=
(
StridedIterator<U>
const
& other) {
74
BOOST_STATIC_ASSERT((boost::is_convertible<U*,T*>::value));
75
_data
= other.
_data
;
76
_stride
= other.
_stride
;
77
return
*
this
;
78
}
79
80
private
:
81
82
friend
class
boost::iterator_core_access
;
83
84
template
<
typename
OtherT>
friend
class
StridedIterator
;
85
86
Reference
dereference
()
const
{
return
*
_data
; }
87
88
void
increment
() {
_data
+=
_stride
; }
89
void
decrement
() {
_data
-=
_stride
; }
90
void
advance
(
int
n) {
_data
+=
_stride
* n; }
91
92
template
<
typename
U>
93
int
distance_to
(
StridedIterator<U>
const
& other)
const
{
94
return
std::distance(
_data
, other.
_data
) /
_stride
;
95
}
96
97
template
<
typename
U>
98
bool
equal
(
StridedIterator<U>
const
& other)
const
{
99
return
_data
== other.
_data
;
100
}
101
102
T *
_data
;
103
int
_stride
;
104
105
};
106
107
}
// namespace detail
108
}
// namespace ndarray
109
110
#endif // !NDARRAY_DETAIL_StridedIterator_h_INCLUDED
ndarray::detail::StridedIterator::StridedIterator
StridedIterator(StridedIterator< U > const &other)
Definition:
StridedIterator.h:60
ndarray::detail::StridedIterator::StridedIterator
StridedIterator(T *data, int stride)
Definition:
StridedIterator.h:55
ndarray::detail::StridedIterator::equal
bool equal(StridedIterator< U > const &other) const
Definition:
StridedIterator.h:98
ndarray::detail::StridedIterator::dereference
Reference dereference() const
Definition:
StridedIterator.h:86
ndarray::detail::StridedIterator::distance_to
int distance_to(StridedIterator< U > const &other) const
Definition:
StridedIterator.h:93
ndarray_fwd.h
Forward declarations and default template parameters for ndarray.
ndarray::detail::StridedIterator::_data
T * _data
Definition:
StridedIterator.h:102
ndarray::detail::StridedIterator::advance
void advance(int n)
Definition:
StridedIterator.h:90
ndarray::detail::StridedIterator::Value
T Value
Definition:
StridedIterator.h:50
ndarray::detail::StridedIterator::increment
void increment()
Definition:
StridedIterator.h:88
ndarray::detail::StridedIterator::StridedIterator
StridedIterator()
Definition:
StridedIterator.h:53
ndarray::detail::StridedIterator::operator=
StridedIterator & operator=(StridedIterator const &other)
Definition:
StridedIterator.h:64
ndarray::detail::StridedIterator::operator=
StridedIterator & operator=(StridedIterator< U > const &other)
Definition:
StridedIterator.h:73
ndarray::detail::StridedIterator::decrement
void decrement()
Definition:
StridedIterator.h:89
ndarray::detail::StridedIterator
Definition:
StridedIterator.h:44
ndarray::detail::StridedIterator::StridedIterator
StridedIterator(StridedIterator const &other)
Definition:
StridedIterator.h:57
ndarray::detail::StridedIterator::iterator_core_access
friend class boost::iterator_core_access
Definition:
StridedIterator.h:82
ndarray::detail::StridedIterator::_stride
int _stride
Definition:
StridedIterator.h:103
ndarray::detail::StridedIterator::Reference
T & Reference
Definition:
StridedIterator.h:51
Generated on Thu Sep 24 2015 02:29:22 for LSSTApplications by
1.8.5