NVBIO
Main Page
Modules
Classes
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
nvbio
basic
deinterleaved_iterator.h
Go to the documentation of this file.
1
/*
2
* nvbio
3
* Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
* * Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* * Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
* * Neither the name of the NVIDIA CORPORATION nor the
13
* names of its contributors may be used to endorse or promote products
14
* derived from this software without specific prior written permission.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
* DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
20
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
#pragma once
29
30
#include <
nvbio/basic/types.h
>
31
#include <
nvbio/basic/iterator.h
>
32
33
namespace
nvbio {
34
38
template
<u
int
32 STRIDE, u
int
32 WHICH,
typename
BaseIterator>
39
struct
deinterleaved_iterator
40
{
41
typedef
typename
std::iterator_traits<BaseIterator>::value_type
value_type
;
42
typedef
typename
std::iterator_traits<BaseIterator>::reference
reference
;
43
typedef
const
value_type
*
pointer
;
44
typedef
int32
difference_type
;
45
typedef
std::random_access_iterator_tag
iterator_category
;
46
47
typedef
deinterleaved_iterator<STRIDE,WHICH,BaseIterator>
this_type
;
48
51
NVBIO_HOST_DEVICE_TEMPLATE
52
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
53
deinterleaved_iterator
() {}
54
57
NVBIO_HOST_DEVICE_TEMPLATE
58
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
59
deinterleaved_iterator
(
const
BaseIterator it) :
m_it
( it ) {}
60
63
NVBIO_HOST_DEVICE_TEMPLATE
64
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
65
deinterleaved_iterator
(
const
deinterleaved_iterator
& it) :
m_it
( it.
m_it
) {}
66
69
NVBIO_HOST_DEVICE_TEMPLATE
70
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
71
value_type
operator[]
(
const
uint32
i)
const
{
return
m_it
[ i*STRIDE + WHICH ]; }
72
75
NVBIO_HOST_DEVICE_TEMPLATE
76
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
77
reference
operator[]
(
const
uint32
i) {
return
m_it
[ i*STRIDE + WHICH ]; }
78
81
NVBIO_HOST_DEVICE_TEMPLATE
82
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
83
reference
operator*
()
const
{
return
m_it
[ WHICH ]; }
84
87
NVBIO_HOST_DEVICE_TEMPLATE
88
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
89
deinterleaved_iterator
&
operator++
()
90
{
91
++
m_it
;
92
return
*
this
;
93
}
94
97
NVBIO_HOST_DEVICE_TEMPLATE
98
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
99
deinterleaved_iterator
operator++
(
int
i)
100
{
101
this_type
r(
m_it
);
102
++
m_it
;
103
return
r;
104
}
105
108
NVBIO_HOST_DEVICE_TEMPLATE
109
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
110
deinterleaved_iterator
&
operator--
()
111
{
112
--
m_it
;
113
return
*
this
;
114
}
115
118
NVBIO_HOST_DEVICE_TEMPLATE
119
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
120
deinterleaved_iterator
operator--
(
int
i)
121
{
122
this_type
r(
m_it
);
123
--
m_it
;
124
return
r;
125
}
126
129
NVBIO_HOST_DEVICE_TEMPLATE
130
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
131
deinterleaved_iterator
operator+
(
const
difference_type
i)
const
132
{
133
return
deinterleaved_iterator
(
m_it
+ i );
134
}
135
138
NVBIO_HOST_DEVICE_TEMPLATE
139
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
140
deinterleaved_iterator
operator-
(
const
difference_type
i)
const
141
{
142
return
this_type
(
m_it
- i );
143
}
144
147
NVBIO_HOST_DEVICE_TEMPLATE
148
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
149
deinterleaved_iterator
&
operator+=
(
const
difference_type
i)
150
{
151
m_it
+= i;
152
return
*
this
;
153
}
154
157
NVBIO_HOST_DEVICE_TEMPLATE
158
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
159
deinterleaved_iterator
&
operator-=
(
const
difference_type
i)
160
{
161
m_it
-= i;
162
return
*
this
;
163
}
164
167
NVBIO_HOST_DEVICE_TEMPLATE
168
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
169
difference_type
operator-
(
const
deinterleaved_iterator
& it)
const
170
{
171
return
m_it
- it.
m_it
;
172
}
173
176
NVBIO_HOST_DEVICE_TEMPLATE
177
NVBIO_FORCEINLINE
NVBIO_HOST_DEVICE
178
deinterleaved_iterator
&
operator=
(
const
deinterleaved_iterator
& it)
179
{
180
m_it
= it.
m_it
;
181
return
*
this
;
182
}
183
184
BaseIterator
m_it
;
185
};
186
187
188
}
// namespace nvbio
Generated on Wed Feb 25 2015 08:32:55 for NVBIO by
1.8.4