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
NestedIterator.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_NestedIterator_h_INCLUDED
24
#define NDARRAY_DETAIL_NestedIterator_h_INCLUDED
25
32
#include <boost/iterator/iterator_facade.hpp>
33
#include "
ndarray_fwd.h
"
34
35
namespace
ndarray {
36
namespace
detail {
37
51
template
<
typename
T,
int
N,
int
C>
52
class
NestedIterator
:
public
boost::iterator_facade<
53
NestedIterator<T,N,C>,
54
typename ArrayTraits<T,N,C>::Value,
55
boost::random_access_traversal_tag,
56
typename ArrayTraits<T,N,C>::Reference
57
>
58
{
59
public
:
60
typedef
typename
ArrayTraits<T,N,C>::Value
Value
;
61
typedef
typename
ArrayTraits<T,N,C>::Reference
Reference
;
62
63
Reference
operator[]
(
int
n)
const
{
64
Reference
r(
_ref
);
65
r.
_data
+= n *
_stride
;
66
return
r;
67
}
68
69
Reference
const
&
operator*
()
const
{
return
_ref
; }
70
71
Reference
const
*
operator->
() {
return
&
_ref
; }
72
73
NestedIterator
() :
_ref
(
Value
()),
_stride
(0) {}
74
75
NestedIterator
(
Reference
const
& ref,
int
stride) :
_ref
(ref),
_stride
(stride) {}
76
77
NestedIterator
(
NestedIterator
const
& other) :
_ref
(other.
_ref
),
_stride
(other.
_stride
) {}
78
79
template
<
typename
T_,
int
C_>
80
NestedIterator
(
NestedIterator<T_,N,C_>
const
& other) :
_ref
(other.
_ref
),
_stride
(other.
_stride
) {}
81
82
NestedIterator
&
operator=
(
NestedIterator
const
& other) {
83
if
(&other !=
this
) {
84
_ref
.
_data
= other.
_ref
.
_data
;
85
_ref
.
_core
= other.
_ref
.
_core
;
86
_stride
= other.
_stride
;
87
}
88
return
*
this
;
89
}
90
91
template
<
typename
T_,
int
C_>
92
NestedIterator
&
operator=
(
NestedIterator<T_,N,C_>
const
& other) {
93
_ref
.
_data
= other.
_ref
.
_data
;
94
_ref
.
_core
= other.
_ref
.
_core
;
95
_stride
= other.
_stride
;
96
return
*
this
;
97
}
98
99
private
:
100
101
friend
class
boost::iterator_core_access
;
102
103
template
<
typename
T_,
int
N_,
int
C_>
friend
class
NestedIterator
;
104
105
Reference
const
&
dereference
()
const
{
return
_ref
; }
106
107
void
increment
() {
_ref
.
_data
+=
_stride
; }
108
void
decrement
() {
_ref
.
_data
-=
_stride
; }
109
void
advance
(
int
n) {
_ref
.
_data
+=
_stride
* n; }
110
111
template
<
typename
T_,
int
C_>
112
int
distance_to
(
NestedIterator<T_,N,C_>
const
& other)
const
{
113
return
std::distance(
_ref
.
_data
, other.
_ref
.
_data
) /
_stride
;
114
}
115
116
template
<
typename
T_,
int
C_>
117
bool
equal
(
NestedIterator<T_,N,C_>
const
& other)
const
{
118
return
_ref
.
_data
== other.
_ref
.
_data
;
119
}
120
121
Reference
_ref
;
122
int
_stride
;
123
};
124
125
}
// namespace detail
126
}
// namespace ndarray
127
128
#endif // !NDARRAY_DETAIL_NestedIterator_h_INCLUDED
ndarray::ArrayRef
A proxy class for Array with deep assignment operators.
Definition:
ArrayRef.h:46
ndarray::detail::NestedIterator::decrement
void decrement()
Definition:
NestedIterator.h:108
ndarray::detail::NestedIterator::equal
bool equal(NestedIterator< T_, N, C_ > const &other) const
Definition:
NestedIterator.h:117
ndarray::detail::NestedIterator::operator[]
Reference operator[](int n) const
Definition:
NestedIterator.h:63
ndarray::detail::NestedIterator::increment
void increment()
Definition:
NestedIterator.h:107
ndarray::ArrayBase::_data
Element * _data
Definition:
ArrayBase.h:227
ndarray::detail::NestedIterator::distance_to
int distance_to(NestedIterator< T_, N, C_ > const &other) const
Definition:
NestedIterator.h:112
ndarray::detail::NestedIterator::operator*
Reference const & operator*() const
Definition:
NestedIterator.h:69
ndarray_fwd.h
Forward declarations and default template parameters for ndarray.
ndarray::detail::NestedIterator::operator=
NestedIterator & operator=(NestedIterator< T_, N, C_ > const &other)
Definition:
NestedIterator.h:92
ndarray::detail::NestedIterator::advance
void advance(int n)
Definition:
NestedIterator.h:109
ndarray::ArrayBase::_core
CorePtr _core
Definition:
ArrayBase.h:228
ndarray::detail::NestedIterator::Reference
ArrayTraits< T, N, C >::Reference Reference
Definition:
NestedIterator.h:61
ndarray::detail::NestedIterator::operator=
NestedIterator & operator=(NestedIterator const &other)
Definition:
NestedIterator.h:82
ndarray::detail::NestedIterator::Value
ArrayTraits< T, N, C >::Value Value
Definition:
NestedIterator.h:60
ndarray::detail::NestedIterator::NestedIterator
NestedIterator()
Definition:
NestedIterator.h:73
ndarray::detail::NestedIterator::NestedIterator
NestedIterator(NestedIterator< T_, N, C_ > const &other)
Definition:
NestedIterator.h:80
ndarray::detail::NestedIterator::_ref
Reference _ref
Definition:
NestedIterator.h:121
ndarray::Array
A multidimensional strided array.
Definition:
Array.h:47
ndarray::detail::NestedIterator::iterator_core_access
friend class boost::iterator_core_access
Definition:
NestedIterator.h:101
ndarray::detail::NestedIterator::NestedIterator
NestedIterator(Reference const &ref, int stride)
Definition:
NestedIterator.h:75
ndarray::detail::NestedIterator::operator->
Reference const * operator->()
Definition:
NestedIterator.h:71
ndarray::detail::NestedIterator::_stride
int _stride
Definition:
NestedIterator.h:122
ndarray::detail::NestedIterator
Definition:
NestedIterator.h:52
ndarray::detail::NestedIterator::dereference
Reference const & dereference() const
Definition:
NestedIterator.h:105
ndarray::detail::NestedIterator::NestedIterator
NestedIterator(NestedIterator const &other)
Definition:
NestedIterator.h:77
Generated on Thu Sep 24 2015 02:29:22 for LSSTApplications by
1.8.5