thrust
Public Member Functions
thrust::device_vector< T, Alloc > Class Template Reference

#include <device_vector.h>

List of all members.

Public Member Functions

__host__ device_vector (void)
__host__ device_vector (size_type n, const value_type &value=value_type())
__host__ device_vector (const device_vector &v)
template<typename OtherT , typename OtherAlloc >
__device__ device_vector (const device_vector< OtherT, OtherAlloc > &v)
template<typename OtherT , typename OtherAlloc >
__device__ device_vectoroperator= (const device_vector< OtherT, OtherAlloc > &v)
template<typename OtherT , typename OtherAlloc >
__host__ device_vector (const std::vector< OtherT, OtherAlloc > &v)
template<typename OtherT , typename OtherAlloc >
__host__ device_vectoroperator= (const std::vector< OtherT, OtherAlloc > &v)
template<typename OtherT , typename OtherAlloc >
__host__ device_vector (const host_vector< OtherT, OtherAlloc > &v)
template<typename InputIterator >
__host__ device_vector (InputIterator first, InputIterator last)
void resize (size_type new_size, const value_type &x=value_type())
 Resizes this vector to the specified number of elements.
size_type size (void) const
size_type max_size (void) const
void reserve (size_type n)
 If n is less than or equal to capacity(), this call has no effect. Otherwise, this method is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
size_type capacity (void) const
void shrink_to_fit (void)
reference operator[] (size_type n)
 Subscript access to the data contained in this vector_dev.
const_reference operator[] (size_type n) const
 Subscript read access to the data contained in this vector_dev.
iterator begin (void)
const_iterator begin (void) const
const_iterator cbegin (void) const
reverse_iterator rbegin (void)
const_reverse_iterator rbegin (void) const
const_reverse_iterator crbegin (void) const
iterator end (void)
const_iterator end (void) const
const_iterator cend (void) const
reverse_iterator rend (void)
const_reverse_iterator rend (void) const
const_reverse_iterator crend (void) const
const_reference front (void) const
reference front (void)
const_reference back (void) const
reference back (void)
pointer data (void)
const_pointer data (void) const
void clear (void)
bool empty (void) const
void push_back (const value_type &x)
void pop_back (void)
void swap (device_vector &v)
iterator erase (iterator pos)
iterator erase (iterator first, iterator last)
iterator insert (iterator position, const T &x)
void insert (iterator position, size_type n, const T &x)
template<typename InputIterator >
void insert (iterator position, InputIterator first, InputIterator last)
void assign (size_type n, const T &x)
template<typename InputIterator >
void assign (InputIterator first, InputIterator last)
allocator_type get_allocator (void) const

Detailed Description

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
class thrust::device_vector< T, Alloc >

A device_vector is a container that supports random access to elements, constant time removal of elements at the end, and linear time insertion and removal of elements at the beginning or in the middle. The number of elements in a device_vector may vary dynamically; memory management is automatic. The memory associated with a device_vector resides in the memory space of a parallel device.

See also:
http://www.sgi.com/tech/stl/Vector.html
host_vector

Constructor & Destructor Documentation

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
__host__ thrust::device_vector< T, Alloc >::device_vector ( void  ) [inline]

This constructor creates an empty device_vector.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
__host__ thrust::device_vector< T, Alloc >::device_vector ( size_type  n,
const value_type &  value = value_type() 
) [inline, explicit]

This constructor creates a device_vector with copies of an exemplar element.

Parameters:
nThe number of elements to initially create.
valueAn element to copy.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
__host__ thrust::device_vector< T, Alloc >::device_vector ( const device_vector< T, Alloc > &  v) [inline]

Copy constructor copies from an exemplar device_vector.

Parameters:
vThe device_vector to copy.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
template<typename OtherT , typename OtherAlloc >
__device__ thrust::device_vector< T, Alloc >::device_vector ( const device_vector< OtherT, OtherAlloc > &  v) [inline]

Copy constructor copies from an exemplar device_vector with different type.

Parameters:
vThe device_vector to copy.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
template<typename OtherT , typename OtherAlloc >
__host__ thrust::device_vector< T, Alloc >::device_vector ( const std::vector< OtherT, OtherAlloc > &  v) [inline]

Copy constructor copies from an exemplar std::vector.

Parameters:
vThe std::vector to copy.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
template<typename OtherT , typename OtherAlloc >
__host__ thrust::device_vector< T, Alloc >::device_vector ( const host_vector< OtherT, OtherAlloc > &  v)

Copy constructor copies from an exemplar host_vector with possibly different type.

Parameters:
vThe host_vector to copy.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
template<typename InputIterator >
__host__ thrust::device_vector< T, Alloc >::device_vector ( InputIterator  first,
InputIterator  last 
) [inline]

This constructor builds a device_vector from a range.

Parameters:
firstThe beginning of the range.
lastThe end of the range.

Member Function Documentation

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::assign ( size_type  n,
const T &  x 
)

This version of assign replicates a given exemplar n times into this vector.

Parameters:
nThe number of times to copy x.
xThe exemplar element to replicate.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
template<typename InputIterator >
void thrust::device_vector< T, Alloc >::assign ( InputIterator  first,
InputIterator  last 
)

This version of assign makes this vector a copy of a given input range.

Parameters:
firstThe beginning of the range to copy.
lastThe end of the range to copy.
Template Parameters:
InputIteratoris a model of Input Iterator.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_reference thrust::device_vector< T, Alloc >::back ( void  ) const

This method returns a const reference pointing to the last element of this vector.

Returns:
The last element of this vector.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
reference thrust::device_vector< T, Alloc >::back ( void  )

This method returns a reference referring to the last element of this vector_dev.

Returns:
The last element of this vector.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
iterator thrust::device_vector< T, Alloc >::begin ( void  )

This method returns an iterator pointing to the beginning of this vector.

Returns:
mStart
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_iterator thrust::device_vector< T, Alloc >::begin ( void  ) const

This method returns a const_iterator pointing to the beginning of this vector.

Returns:
mStart
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
size_type thrust::device_vector< T, Alloc >::capacity ( void  ) const

Returns the number of elements which have been reserved in this vector.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_iterator thrust::device_vector< T, Alloc >::cbegin ( void  ) const

This method returns a const_iterator pointing to the beginning of this vector.

Returns:
mStart
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_iterator thrust::device_vector< T, Alloc >::cend ( void  ) const

This method returns a const_iterator pointing to one element past the last of this vector.

Returns:
begin() + size().
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::clear ( void  )

This method resizes this vector to 0.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_reverse_iterator thrust::device_vector< T, Alloc >::crbegin ( void  ) const

This method returns a const_reverse_iterator pointing to the beginning of this vector's reversed sequence.

Returns:
A const_reverse_iterator pointing to the beginning of this vector's reversed sequence.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_reverse_iterator thrust::device_vector< T, Alloc >::crend ( void  ) const

This method returns a const_reverse_iterator pointing to one element past the last of this vector's reversed sequence.

Returns:
rbegin() + size().
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
pointer thrust::device_vector< T, Alloc >::data ( void  )

This method returns a pointer to this vector's first element.

Returns:
A pointer to the first element of this vector.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_pointer thrust::device_vector< T, Alloc >::data ( void  ) const

This method returns a const_pointer to this vector's first element.

Returns:
a const_pointer to the first element of this vector.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
bool thrust::device_vector< T, Alloc >::empty ( void  ) const

This method returns true iff size() == 0.

Returns:
true if size() == 0; false, otherwise.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
iterator thrust::device_vector< T, Alloc >::end ( void  )

This method returns an iterator pointing to one element past the last of this vector.

Returns:
begin() + size().
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_iterator thrust::device_vector< T, Alloc >::end ( void  ) const

This method returns a const_iterator pointing to one element past the last of this vector.

Returns:
begin() + size().
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
iterator thrust::device_vector< T, Alloc >::erase ( iterator  pos)

This method removes the element at position pos.

Parameters:
posThe position of the element of interest.
Returns:
An iterator pointing to the new location of the element that followed the element at position pos.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
iterator thrust::device_vector< T, Alloc >::erase ( iterator  first,
iterator  last 
)

This method removes the range of elements [first,last) from this vector.

Parameters:
firstThe beginning of the range of elements to remove.
lastThe end of the range of elements to remove.
Returns:
An iterator pointing to the new location of the element that followed the last element in the sequence [first,last).
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_reference thrust::device_vector< T, Alloc >::front ( void  ) const

This method returns a const_reference referring to the first element of this vector.

Returns:
The first element of this vector.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
reference thrust::device_vector< T, Alloc >::front ( void  )

This method returns a reference pointing to the first element of this vector.

Returns:
The first element of this vector.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
allocator_type thrust::device_vector< T, Alloc >::get_allocator ( void  ) const

This method returns a copy of this vector's allocator.

Returns:
A copy of the alloctor used by this vector.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
iterator thrust::device_vector< T, Alloc >::insert ( iterator  position,
const T &  x 
)

This method inserts a single copy of a given exemplar value at the specified position in this vector.

Parameters:
positionThe insertion position.
xThe exemplar element to copy & insert.
Returns:
An iterator pointing to the newly inserted element.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
template<typename InputIterator >
void thrust::device_vector< T, Alloc >::insert ( iterator  position,
InputIterator  first,
InputIterator  last 
)

This method inserts a copy of an input range at the specified position in this vector.

Parameters:
positionThe insertion position.
firstThe beginning of the range to copy.
lastThe end of the range to copy.
Template Parameters:
InputIteratoris a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html>Input Iterator</a>, and \p InputIterator's \c value_type is a model of <a href="http://www.sgi.com/tech/stl/Assignable.html">Assignable.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::insert ( iterator  position,
size_type  n,
const T &  x 
)

This method inserts a copy of an exemplar value to a range at the specified position in this vector.

Parameters:
positionThe insertion position
nThe number of insertions to perform.
xThe value to replicate and insert.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
size_type thrust::device_vector< T, Alloc >::max_size ( void  ) const

Returns the size() of the largest possible vector.

Returns:
The largest possible return value of size().
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
template<typename OtherT , typename OtherAlloc >
__device__ device_vector& thrust::device_vector< T, Alloc >::operator= ( const device_vector< OtherT, OtherAlloc > &  v) [inline]

Assign operator copies from an exemplar device_vector with different type.

Parameters:
vThe device_vector to copy.

Referenced by thrust::device_vector< T, Alloc >::operator=().

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
template<typename OtherT , typename OtherAlloc >
__host__ device_vector& thrust::device_vector< T, Alloc >::operator= ( const std::vector< OtherT, OtherAlloc > &  v) [inline]

Assign operator copies from an exemplar std::vector.

Parameters:
vThe std::vector to copy.

References thrust::device_vector< T, Alloc >::operator=().

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
reference thrust::device_vector< T, Alloc >::operator[] ( size_type  n)

Subscript access to the data contained in this vector_dev.

Parameters:
nThe index of the element for which data should be accessed.
Returns:
Read/write reference to data.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_reference thrust::device_vector< T, Alloc >::operator[] ( size_type  n) const

Subscript read access to the data contained in this vector_dev.

Parameters:
nThe index of the element for which data should be accessed.
Returns:
Read reference to data.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::pop_back ( void  )

This method erases the last element of this vector, invalidating all iterators and references to it.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::push_back ( const value_type &  x)

This method appends the given element to the end of this vector.

Parameters:
xThe element to append.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
reverse_iterator thrust::device_vector< T, Alloc >::rbegin ( void  )

This method returns a reverse_iterator pointing to the beginning of this vector's reversed sequence.

Returns:
A reverse_iterator pointing to the beginning of this vector's reversed sequence.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_reverse_iterator thrust::device_vector< T, Alloc >::rbegin ( void  ) const

This method returns a const_reverse_iterator pointing to the beginning of this vector's reversed sequence.

Returns:
A const_reverse_iterator pointing to the beginning of this vector's reversed sequence.
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
const_reverse_iterator thrust::device_vector< T, Alloc >::rend ( void  ) const

This method returns a const_reverse_iterator pointing to one element past the last of this vector's reversed sequence.

Returns:
rbegin() + size().
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
reverse_iterator thrust::device_vector< T, Alloc >::rend ( void  )

This method returns a reverse_iterator pointing to one element past the last of this vector's reversed sequence.

Returns:
rbegin() + size().
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::reserve ( size_type  n)

If n is less than or equal to capacity(), this call has no effect. Otherwise, this method is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged.

Exceptions:
std::length_errorIf n exceeds max_size().
template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::resize ( size_type  new_size,
const value_type &  x = value_type() 
)

Resizes this vector to the specified number of elements.

Parameters:
new_sizeNumber of elements this vector should contain.
xData with which new elements should be populated.
Exceptions:
std::length_errorIf n exceeds max_size().

This method will resize this vector to the specified number of elements. If the number is smaller than this vector's current size this vector is truncated, otherwise this vector is extended and new elements are populated with given data.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::shrink_to_fit ( void  )

This method shrinks the capacity of this vector to exactly fit its elements.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
size_type thrust::device_vector< T, Alloc >::size ( void  ) const

Returns the number of elements in this vector.

template<typename T, typename Alloc = thrust::device_malloc_allocator<T>>
void thrust::device_vector< T, Alloc >::swap ( device_vector< T, Alloc > &  v)

This method swaps the contents of this vector_base with another vector.

Parameters:
vThe vector with which to swap.

The documentation for this class was generated from the following file: