87 template <
typename Iterator,
typename IndexType = u
int32>
158 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
159 reference operator[](const IndexType i) { NVBIO_CUDA_DEBUG_ASSERT( i < m_size, "vector_view: access out of bounds, %llu >= %llu\n
", uint64(i), uint64(m_size) ); return m_vec[i]; }
163 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
164 const_reference front(void) const { return m_vec[0]; }
168 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
169 reference front(void) { return m_vec[0]; }
173 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
174 const_reference back(void) const { return m_vec[m_size-1]; }
178 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
179 reference back(void) { return m_vec[m_size-1]; }
183 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
184 Iterator base() const { return m_vec; }
188 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
189 const_iterator begin() const { return m_vec; }
193 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
194 const_iterator end() const { return m_vec + m_size; }
198 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
199 iterator begin() { return m_vec; }
203 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
204 iterator end() { return m_vec + m_size; }
208 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
209 operator Iterator() const { return m_vec; }
213 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
214 void push_back(const_reference val) { m_vec[ m_size ] = val; m_size++; }
218 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
219 void pop_back() { --m_size; }
228 template <typename Iterator, typename IndexType>
229 struct string_traits< vector_view<Iterator,IndexType> >
231 static const uint32 SYMBOL_SIZE = string_traits<Iterator>::SYMBOL_SIZE;
233 typedef typename vector_view<Iterator,IndexType>::value_type value_type;
234 typedef typename vector_view<Iterator,IndexType>::reference reference;
235 typedef typename vector_view<Iterator,IndexType>::index_type index_type;
236 typedef typename vector_view<Iterator,IndexType>::iterator iterator;
237 typedef typename vector_view<Iterator,IndexType>::const_iterator const_iterator;
238 typedef typename vector_view<Iterator,IndexType>::forward_iterator forward_iterator;
243 template <typename Iterator>
244 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
245 uint32 length(const vector_view<Iterator>& vec) { return vec.length(); }
249 template <typename T>
250 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
251 T raw_pointer(const vector_view<T>& vec) { return vec.base(); }
255 template <typename T, typename I>
256 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
257 T begin(vector_view<T,I>& vec) { return vec.begin(); }
261 template <typename T, typename I>
262 NVBIO_FORCEINLINE NVBIO_HOST_DEVICE
263 T begin(const vector_view<T,I>& vec) { return vec.begin(); }
266 // --- std::vector views ----------------------------------------------------------------------------
271 template <typename T> struct plain_view_subtype< std::vector<T> > { typedef vector_view<T*,uint64> type; };
275 template <typename T> struct plain_view_subtype< const std::vector<T> > { typedef vector_view<const T*,uint64> type; };
280 template <typename T>
281 vector_view<T*,uint64> plain_view(std::vector<T>& vec) { return vector_view<T*,uint64>( vec.size(), vec.size() ? &vec[0] : NULL ); }
285 template <typename T>
286 vector_view<const T*,uint64> plain_view(const std::vector<T>& vec) { return vector_view<const T*,uint64>( vec.size(), vec.size() ? &vec[0] : NULL ); }
290 template <typename T>
291 T* raw_pointer(std::vector<T>& vec) { return vec.size() ? &vec[0] : NULL; }
295 template <typename T>
296 const T* raw_pointer(const std::vector<T>& vec) { return vec.size() ? &vec[0] : NULL; }
300 template <typename T> T* begin(T* vec) { return vec; }
304 template <typename T> const T* begin(const T* vec) { return vec; }