Extended CUDA Library (ecuda)  2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Types | Public Member Functions | Friends | List of all members
ecuda::vector< T, Alloc, P > Class Template Reference

A resizable vector stored in device memory. More...

#include <vector.hpp>

Inheritance diagram for ecuda::vector< T, Alloc, P >:

Public Types

typedef base_type::value_type value_type
 cell data type More...
 
typedef Alloc allocator_type
 allocator type More...
 
typedef base_type::size_type size_type
 unsigned integral type More...
 
typedef base_type::difference_type difference_type
 signed integral type More...
 
typedef Alloc::reference reference
 cell reference type More...
 
typedef Alloc::const_reference const_reference
 cell const reference type More...
 
typedef Alloc::pointer pointer
 cell pointer type More...
 
typedef Alloc::const_pointer const_pointer
 cell const pointer type More...
 
typedef base_type::iterator iterator
 iterator type More...
 
typedef base_type::const_iterator const_iterator
 const iterator type More...
 
typedef base_type::reverse_iterator reverse_iterator
 reverse iterator type More...
 
typedef
base_type::const_reverse_iterator 
const_reverse_iterator
 const reverse iterator type More...
 
typedef
impl::vector_kernel_argument
< T, Alloc > 
kernel_argument
 kernel argument type More...
 
typedef const
impl::vector_kernel_argument
< T, Alloc > 
const_kernel_argument
 const kernel argument type More...
 

Public Member Functions

__HOST__ vector (const allocator_type &allocator=allocator_type())
 Default constructor. Constructs empty container. More...
 
__HOST__ vector (size_type n, const value_type &value, const allocator_type &allocator=allocator_type())
 Constructs the container with n copies of elements with value value. More...
 
__HOST__ vector (size_type n)
 Constructs the container with n default-inserted instances of T. No copies are made. More...
 
template<class Iterator >
__HOST__ vector (Iterator first, Iterator last, const allocator_type &allocator=allocator_type())
 Constructs the container with the contents of the range [begin,end). More...
 
__HOST__ vector (const vector &src)
 Copy constructor. More...
 
__HOST__ vectoroperator= (const vector &src)
 
__HOST__ __DEVICE__ iterator begin () __NOEXCEPT__
 Returns an iterator to the first element of the container. More...
 
__HOST__ __DEVICE__ iterator end () __NOEXCEPT__
 Returns an iterator to the element following the last element of the container. More...
 
__HOST__ __DEVICE__ const_iterator begin () const __NOEXCEPT__
 Returns an iterator to the first element of the container. More...
 
__HOST__ __DEVICE__ const_iterator end () const __NOEXCEPT__
 Returns an iterator to the element following the last element of the container. More...
 
__HOST__ __DEVICE__
reverse_iterator 
rbegin () __NOEXCEPT__
 Returns a reverse iterator to the first element of the reversed container. More...
 
__HOST__ __DEVICE__
reverse_iterator 
rend () __NOEXCEPT__
 Returns a reverse iterator to the element following the last element of the reversed container. More...
 
__HOST__ __DEVICE__
const_reverse_iterator 
rbegin () const __NOEXCEPT__
 Returns a reverse iterator to the first element of the reversed container. More...
 
__HOST__ __DEVICE__
const_reverse_iterator 
rend () const __NOEXCEPT__
 Returns a reverse iterator to the element following the last element of the reversed container. More...
 
__HOST__ __DEVICE__ size_type size () const __NOEXCEPT__
 Returns the number of elements in the container. More...
 
__HOST__ __DEVICE__
__CONSTEXPR__ size_type 
max_size () const __NOEXCEPT__
 Returns the maximum number of elements the container is able to hold due to system or library implementation limitations. More...
 
__HOST__ void resize (size_type newSize, const value_type &value=value_type())
 Resizes the container to contain newSize elements. More...
 
__HOST__ __DEVICE__ size_type capacity () const __NOEXCEPT__
 Returns the number of elements that the container has currently allocated space for. More...
 
__HOST__ __DEVICE__ bool empty () const __NOEXCEPT__
 Checks if the container has no elements. More...
 
__HOST__ void reserve (size_type newCapacity)
 Increase the capacity of the container to a value that's greater or equal to newCapacity. More...
 
__DEVICE__ reference at (size_type index)
 Returns a reference to the element at specified location index, with bounds checking. More...
 
__DEVICE__ const_reference at (size_type index) const
 Returns a reference to the element at specified location index, with bounds checking. More...
 
__DEVICE__ reference operator[] (const size_type index)
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ const_reference operator[] (const size_type index) const
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ reference operator() (const size_type index)
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ const_reference operator() (const size_type index) const
 Returns a reference to the element at specified location index. No bounds checking is performed. More...
 
__DEVICE__ reference front ()
 Returns a reference to the first element in the container. More...
 
__DEVICE__ reference back ()
 Returns a reference to the last element in the container. More...
 
__DEVICE__ const_reference front () const
 Returns a reference to the first element in the container. More...
 
__DEVICE__ const_reference back () const
 Returns a reference to the last element in the container. More...
 
__HOST__ __DEVICE__ pointer data () __NOEXCEPT__
 Returns pointer to the underlying array serving as element storage. More...
 
__HOST__ __DEVICE__ const_pointer data () const __NOEXCEPT__
 Returns pointer to the underlying array serving as element storage. More...
 
__HOST__ void assign (size_type newSize, const value_type &value=value_type())
 Replaces the contents of the container. More...
 
template<class Iterator >
__HOST__ void assign (Iterator first, Iterator last)
 Replaces the contents of the container with copies of those in the range [first,last). More...
 
__HOST__ void push_back (const value_type &value)
 Appends the given element value to the end of the container. More...
 
__HOST__ __DEVICE__ void pop_back ()
 Removes the last element of the container. More...
 
__HOST__ iterator insert (const_iterator position, const value_type &value)
 Inserts value before position. More...
 
__HOST__ iterator insert (const_iterator position, const size_type count, const value_type &value)
 Inserts count copies of the value before position. More...
 
template<class InputIterator >
__HOST__ void insert (const_iterator position, InputIterator first, InputIterator last)
 Inserts elements from range [first,last) before position. More...
 
__HOST__ iterator erase (const_iterator position)
 Removes the element at position. More...
 
__HOST__ iterator erase (const_iterator first, const_iterator last)
 Removes the elements in the range [first,last). More...
 
__HOST__ __DEVICE__ void swap (vector &other)
 Exchanges the contents of the container with those of the other. More...
 
__HOST__ __DEVICE__ void clear ()
 Removes all elements from the container. More...
 
__HOST__ allocator_type get_allocator () const
 Returns the allocator associated with the container. More...
 
__HOST__ void shrink_to_fit ()
 Requests the removal of unused capacity. More...
 
__HOST__ __DEVICE__ bool operator== (const vector &other) const
 Checks if the contents of two vectors are equal. More...
 
__HOST__ __DEVICE__ bool operator!= (const vector &other) const
 Checks if the contents of two arrays are not equal. More...
 
__HOST__ __DEVICE__ bool operator< (const vector &other) const
 Compares the contents of two vectors lexicographically. More...
 
__HOST__ __DEVICE__ bool operator> (const vector &other) const
 Compares the contents of two vectors lexicographically. More...
 
__HOST__ __DEVICE__ bool operator<= (const vector &other) const
 Compares the contents of two vectors lexicographically. More...
 
__HOST__ __DEVICE__ bool operator>= (const vector &other) const
 Compares the contents of two vectors lexicographically. More...
 

Friends

template<typename U , class Alloc2 , class Q >
class vector
 

Detailed Description

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
class ecuda::vector< T, Alloc, P >

A resizable vector stored in device memory.

Methods are prefaced with appropriate keywords to declare them as host and/or device capable. In general: operations requiring memory allocation/deallocation are host only, operations to access the values of specific elements are device only, and copy operations on ranges of data and accessors of general information can be performed on both the host and device.

Any growth of the vector follows a doubling pattern. The existing memory allocation size is doubled until the requested amount of memory is met or exceeded. In practice, vector growth, element insertions and so on, will be far faster with host memory and so it is preferred to do these kinds of operations in host code and then copy the final result into device memory.

// slow
ecuda::vector<double> deviceVector;
for( size_t i = 0; i < 100; ++i ) deviceVector.push_back( static_cast<double>(i) );
// fast
std::vector<double> hostVector;
for( size_t i = 0; i < 100; ++i ) hostVector.push_back( static_cast<double>(i) );
ecuda::vector<double> deviceVector( hostVector.begin(), hostVector.end() );

Definition at line 96 of file vector.hpp.

Member Typedef Documentation

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef Alloc ecuda::vector< T, Alloc, P >::allocator_type

allocator type

Definition at line 103 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef base_type::const_iterator ecuda::vector< T, Alloc, P >::const_iterator

const iterator type

Definition at line 119 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef const impl::vector_kernel_argument<T,Alloc> ecuda::vector< T, Alloc, P >::const_kernel_argument

const kernel argument type

Definition at line 124 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef Alloc::const_pointer ecuda::vector< T, Alloc, P >::const_pointer

cell const pointer type

Definition at line 115 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef Alloc::const_reference ecuda::vector< T, Alloc, P >::const_reference

cell const reference type

Definition at line 113 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef base_type::const_reverse_iterator ecuda::vector< T, Alloc, P >::const_reverse_iterator

const reverse iterator type

Definition at line 121 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef base_type::difference_type ecuda::vector< T, Alloc, P >::difference_type

signed integral type

Definition at line 105 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef base_type::iterator ecuda::vector< T, Alloc, P >::iterator

iterator type

Definition at line 118 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef impl::vector_kernel_argument<T,Alloc> ecuda::vector< T, Alloc, P >::kernel_argument

kernel argument type

Definition at line 123 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef Alloc::pointer ecuda::vector< T, Alloc, P >::pointer

cell pointer type

Definition at line 114 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef Alloc::reference ecuda::vector< T, Alloc, P >::reference

cell reference type

Definition at line 112 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef base_type::reverse_iterator ecuda::vector< T, Alloc, P >::reverse_iterator

reverse iterator type

Definition at line 120 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef base_type::size_type ecuda::vector< T, Alloc, P >::size_type

unsigned integral type

Definition at line 104 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
typedef base_type::value_type ecuda::vector< T, Alloc, P >::value_type

cell data type

Definition at line 102 of file vector.hpp.

Constructor & Destructor Documentation

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ ecuda::vector< T, Alloc, P >::vector ( const allocator_type allocator = allocator_type())
inlineexplicit

Default constructor. Constructs empty container.

Parameters
allocatorallocator to use for all memory allocations of this container

Definition at line 176 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ ecuda::vector< T, Alloc, P >::vector ( size_type  n,
const value_type value,
const allocator_type allocator = allocator_type() 
)
inlineexplicit

Constructs the container with n copies of elements with value value.

Parameters
nthe size of the container
valuethe value to initialize elements of the container with
allocatorallocator to use for all memory allocations of this container

Definition at line 184 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ ecuda::vector< T, Alloc, P >::vector ( size_type  n)
inlineexplicit

Constructs the container with n default-inserted instances of T. No copies are made.

Parameters
nthe size of the container

Definition at line 193 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
template<class Iterator >
__HOST__ ecuda::vector< T, Alloc, P >::vector ( Iterator  first,
Iterator  last,
const allocator_type allocator = allocator_type() 
)
inline

Constructs the container with the contents of the range [begin,end).

Parameters
first,lastthe range to copy the elements from
allocatorallocator to use for all memory allocations of this container

Definition at line 204 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ ecuda::vector< T, Alloc, P >::vector ( const vector< T, Alloc, P > &  src)
inline

Copy constructor.

Constructs a vector with a copy of the contents of src.

Parameters
srcAnother vector object of the same type and size, whose contents are copied.

Definition at line 217 of file vector.hpp.

Member Function Documentation

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ void ecuda::vector< T, Alloc, P >::assign ( size_type  newSize,
const value_type value = value_type() 
)
inline

Replaces the contents of the container.

Parameters
newSizethe new size of the container
valuethe value to initialize elements of the container with

Definition at line 558 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
template<class Iterator >
__HOST__ void ecuda::vector< T, Alloc, P >::assign ( Iterator  first,
Iterator  last 
)
inline

Replaces the contents of the container with copies of those in the range [first,last).

Parameters
first,lastthe range to copy the elements from

Definition at line 570 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::vector< T, Alloc, P >::at ( size_type  index)
inline

Returns a reference to the element at specified location index, with bounds checking.

If index is not within the range of the container, the current kernel will exit and cudaGetLastError will return cudaErrorUnknown.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 420 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::vector< T, Alloc, P >::at ( size_type  index) const
inline

Returns a reference to the element at specified location index, with bounds checking.

If index is not within the range of the container, the current kernel will exit and cudaGetLastError will return cudaErrorUnknown.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 445 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::vector< T, Alloc, P >::back ( )
inline

Returns a reference to the last element in the container.

Calling back on an empty container is undefined.

Returns
Reference to the last element.

Definition at line 513 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::vector< T, Alloc, P >::back ( ) const
inline

Returns a reference to the last element in the container.

Calling back on an empty container is undefined.

Returns
Reference to the last element.

Definition at line 531 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ iterator ecuda::vector< T, Alloc, P >::begin ( )
inline

Returns an iterator to the first element of the container.

If the container is empty, the returned iterator will be equal to end().

Returns
Iterator to the first element.

Definition at line 277 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_iterator ecuda::vector< T, Alloc, P >::begin ( ) const
inline

Returns an iterator to the first element of the container.

If the container is empty, the returned iterator will be equal to end().

Returns
Iterator to the first element.

Definition at line 295 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ size_type ecuda::vector< T, Alloc, P >::capacity ( ) const
inline

Returns the number of elements that the container has currently allocated space for.

Returns
Capacity of the currently allocated storage.

Definition at line 389 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ void ecuda::vector< T, Alloc, P >::clear ( )
inline

Removes all elements from the container.

Invalidates all references, pointers, or iterators referring to contained elements. May invalidate any past-the-end iterators. Leaves the capacity() of the vector unchanged.

Although this can be called from both the host and device, a call from the device only clears the contents of the container in the calling thread only.

Definition at line 781 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ pointer ecuda::vector< T, Alloc, P >::data ( )
inline

Returns pointer to the underlying array serving as element storage.

The pointer is such that range [data(),data()+size()) is always a valid range, even if the container is empty.

Returns
Pointer to the underlying element storage.

Definition at line 541 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_pointer ecuda::vector< T, Alloc, P >::data ( ) const
inline

Returns pointer to the underlying array serving as element storage.

The pointer is such that range [data(),data()+size()) is always a valid range, even if the container is empty.

Returns
Pointer to the underlying element storage.

Definition at line 551 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::vector< T, Alloc, P >::empty ( ) const
inline

Checks if the container has no elements.

Returns
true if the container is empty, false otherwise.

Definition at line 396 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ iterator ecuda::vector< T, Alloc, P >::end ( )
inline

Returns an iterator to the element following the last element of the container.

The element acts as a placeholder; attempting to access it results in undefined behaviour.

Returns
Iterator to the element following the last element.

Definition at line 286 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_iterator ecuda::vector< T, Alloc, P >::end ( ) const
inline

Returns an iterator to the element following the last element of the container.

The element acts as a placeholder; attempting to access it results in undefined behaviour.

Returns
Iterator to the element following the last element.

Definition at line 304 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ iterator ecuda::vector< T, Alloc, P >::erase ( const_iterator  position)
inline

Removes the element at position.

Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator position must be valid and dereferencable. Thus the end() iterator (which is valid, but not dereferencable) cannot be used as a value for position.

Parameters
positioniterator to the element to remove
Returns
Iterator following the last removed element. If the iterator position refers to the last element, the end() iterator is returned.

Definition at line 726 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ iterator ecuda::vector< T, Alloc, P >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Removes the elements in the range [first,last).

Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator position must be valid and dereferencable. Thus the end() iterator (which is valid, but not dereferencable) cannot be used as a value for position. The iterator first does not need to be dereferencable if first==last: erasing an empty range is a no-op.

Parameters
first,lastrange of elements to remove
Returns
Iterator following the last removed element. If the iterator position refers to the last element, the end() iterator is returned.

Definition at line 747 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::vector< T, Alloc, P >::front ( )
inline

Returns a reference to the first element in the container.

Calling front on an empty container is undefined.

Returns
Reference to the first element.

Definition at line 504 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::vector< T, Alloc, P >::front ( ) const
inline

Returns a reference to the first element in the container.

Calling front on an empty container is undefined.

Returns
Reference to the first element.

Definition at line 522 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ allocator_type ecuda::vector< T, Alloc, P >::get_allocator ( ) const
inline

Returns the allocator associated with the container.

Returns
The associated allocator.

Definition at line 787 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ iterator ecuda::vector< T, Alloc, P >::insert ( const_iterator  position,
const value_type value 
)
inline

Inserts value before position.

Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Parameters
positioniterator before which the content will be inserted. position may be the end() iterator
valueelement value to insert
Returns
iterator pointing to the inserted value

Definition at line 628 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ iterator ecuda::vector< T, Alloc, P >::insert ( const_iterator  position,
const size_type  count,
const value_type value 
)
inline

Inserts count copies of the value before position.

Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Parameters
positioniterator before which the content will be inserted. position may be the end() iterator
countnumber of copies of value to insert
valueelement value to insert
Returns
iterator pointing to the inserted value

Definition at line 655 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
template<class InputIterator >
__HOST__ void ecuda::vector< T, Alloc, P >::insert ( const_iterator  position,
InputIterator  first,
InputIterator  last 
)
inline

Inserts elements from range [first,last) before position.

Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Parameters
positioniterator before which the content will be inserted. position may be the end() iterator
first,lastthe range of elements to insert, can't be iterators into container for which insert is called

Definition at line 680 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ __CONSTEXPR__ size_type ecuda::vector< T, Alloc, P >::max_size ( ) const
inline

Returns the maximum number of elements the container is able to hold due to system or library implementation limitations.

Returns
Maximum number of elements.

Definition at line 364 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::vector< T, Alloc, P >::operator!= ( const vector< T, Alloc, P > &  other) const
inline

Checks if the contents of two arrays are not equal.

That is, whether size() != other.size() or whether any element in the this vector does not compare equal to the element in the other vector at the same position.

Parameters
othercontainer to compare contents with
Returns
true if the contents are not equal, false otherwise

Definition at line 836 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::vector< T, Alloc, P >::operator() ( const size_type  index)
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

This is identical to operator[] but is present for consistency with higher-dimensional containers.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 485 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::vector< T, Alloc, P >::operator() ( const size_type  index) const
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

This is identical to operator[] but is present for consistency with higher-dimensional containers.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 495 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::vector< T, Alloc, P >::operator< ( const vector< T, Alloc, P > &  other) const
inline

Compares the contents of two vectors lexicographically.

Parameters
othercontainer to compare contents with
Returns
true if the contents of this vector are lexicographically less than the other vector, false otherwise

Definition at line 844 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::vector< T, Alloc, P >::operator<= ( const vector< T, Alloc, P > &  other) const
inline

Compares the contents of two vectors lexicographically.

Parameters
othercontainer to compare contents with
Returns
true if the contents of this vector are lexicographically less than or equal to the other vector, false otherwise

Definition at line 880 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ vector& ecuda::vector< T, Alloc, P >::operator= ( const vector< T, Alloc, P > &  src)
inline

Definition at line 227 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::vector< T, Alloc, P >::operator== ( const vector< T, Alloc, P > &  other) const
inline

Checks if the contents of two vectors are equal.

That is, whether size() == other.size() and each element in the this vector compares equal with the element in the other vector at the same position.

Parameters
othercontainer to compare contents with
Returns
true if the contents are equal, false otherwise

Definition at line 814 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::vector< T, Alloc, P >::operator> ( const vector< T, Alloc, P > &  other) const
inline

Compares the contents of two vectors lexicographically.

Parameters
othercontainer to compare contents with
Returns
true if the contents of this vector are lexicographically greater than the other vector, false otherwise

Definition at line 862 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ bool ecuda::vector< T, Alloc, P >::operator>= ( const vector< T, Alloc, P > &  other) const
inline

Compares the contents of two vectors lexicographically.

Parameters
othercontainer to compare contents with
Returns
true if the contents of this vector are lexicographically greater than or equal to the other vector, false otherwise

Definition at line 888 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ reference ecuda::vector< T, Alloc, P >::operator[] ( const size_type  index)
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 467 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__DEVICE__ const_reference ecuda::vector< T, Alloc, P >::operator[] ( const size_type  index) const
inline

Returns a reference to the element at specified location index. No bounds checking is performed.

Parameters
indexposition of the element to return
Returns
Reference to the requested element.

Definition at line 475 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ void ecuda::vector< T, Alloc, P >::pop_back ( )
inline

Removes the last element of the container.

Calling pop_back on an empty container is undefined. No iterators or references expect for back() and end() are invalidated.

Although this can be called from both the host and device, a call from the device removes the last element of the container in the calling thread only.

Definition at line 614 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ void ecuda::vector< T, Alloc, P >::push_back ( const value_type value)
inline

Appends the given element value to the end of the container.

Parameters
valuethe value of the element to append

Definition at line 598 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ reverse_iterator ecuda::vector< T, Alloc, P >::rbegin ( )
inline

Returns a reverse iterator to the first element of the reversed container.

It corresponds to the last element of the non-reversed container.

Returns
Reverse iterator to the first element.

Definition at line 313 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_reverse_iterator ecuda::vector< T, Alloc, P >::rbegin ( ) const
inline

Returns a reverse iterator to the first element of the reversed container.

It corresponds to the last element of the non-reversed container.

Returns
Reverse iterator to the first element.

Definition at line 332 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ reverse_iterator ecuda::vector< T, Alloc, P >::rend ( )
inline

Returns a reverse iterator to the element following the last element of the reversed container.

It corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behaviour.

Returns
Reverse iterator to the element following the last element.

Definition at line 323 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ const_reverse_iterator ecuda::vector< T, Alloc, P >::rend ( ) const
inline

Returns a reverse iterator to the element following the last element of the reversed container.

It corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behaviour.

Returns
Reverse iterator to the element following the last element.

Definition at line 342 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ void ecuda::vector< T, Alloc, P >::reserve ( size_type  newCapacity)
inline

Increase the capacity of the container to a value that's greater or equal to newCapacity.

If newCapacity is greater than the current capacity(), new storage is allocated, otherwise the method does nothing.

If newCapacity is greater than capacity(), all iterators and references, including the past-the-end iterator, are invalidated. Otherwise, no iterators or references are invalidated.

Parameters
newCapacitynew capacity of the container

Definition at line 409 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ void ecuda::vector< T, Alloc, P >::resize ( size_type  newSize,
const value_type value = value_type() 
)
inline

Resizes the container to contain newSize elements.

If the current size is greater than newSize, the container is reduced to its first newSize elements as if by repeatedly calling pop_back().

Parameters
newSizenew size of the container
valuethe value to initialize the new elements with

Definition at line 375 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ void ecuda::vector< T, Alloc, P >::shrink_to_fit ( )
inline

Requests the removal of unused capacity.

The STL specification describes this as a non-binding request to reduce capacity() to size() and it depends on the implementation if the request is fulfilled. In this implementation, the request is always fulfilled. All iterators, including the past the end iterator, are potentially invalidated.

Definition at line 797 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ size_type ecuda::vector< T, Alloc, P >::size ( ) const
inline

Returns the number of elements in the container.

Returns
The number of elements in the container.

Definition at line 356 of file vector.hpp.

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
__HOST__ __DEVICE__ void ecuda::vector< T, Alloc, P >::swap ( vector< T, Alloc, P > &  other)
inline

Exchanges the contents of the container with those of the other.

Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated.

Although this can be called from both the host and device, a call from the device only swaps the contents of the containers in the calling thread only.

Parameters
othercontainer to exchange the contents with

Definition at line 766 of file vector.hpp.

Friends And Related Function Documentation

template<typename T, class Alloc = device_allocator<T>, class P = shared_ptr<T>>
template<typename U , class Alloc2 , class Q >
friend class vector
friend

Definition at line 130 of file vector.hpp.


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