OpenCL C++ Wrapper API 1.1
 All Classes Namespaces Files Functions Variables Typedefs Defines
Classes | Public Member Functions | Private Attributes
cl::vector< T, N > Class Template Reference

Fixed sized vector implementation that mirroring std::vector functionality. More...

#include <cl.hpp>

List of all members.

Classes

class  iterator
 Iterator class for vectors. More...

Public Member Functions

 vector ()
 ~vector ()
unsigned int size (void) const
void clear ()
void push_back (const T &x)
void pop_back (void)
 vector (const vector< T, N > &vec)
 vector (unsigned int size, const T &val=T())
vector< T, N > & operator= (const vector< T, N > &rhs)
bool operator== (vector< T, N > &vec)
 operator T * ()
 operator const T * () const
bool empty (void) const
unsigned int max_size (void) const
unsigned int capacity () const
T & operator[] (int index)
operator[] (int index) const
template<class I >
void assign (I start, I end)
iterator begin (void)
iterator end (void)
T & front (void)
T & back (void)
const T & front (void) const
const T & back (void) const

Private Attributes

data_ [N]
unsigned int size_
bool empty_

Detailed Description

template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
class cl::vector< T, N >

Fixed sized vector implementation that mirroring std::vector functionality.

Definition at line 447 of file cl.hpp.


Constructor & Destructor Documentation

template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
cl::vector< T, N >::vector ( ) [inline]

Definition at line 454 of file cl.hpp.

             : 
        size_(static_cast<unsigned int>(-1)),
        empty_(true)
    {}
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
cl::vector< T, N >::~vector ( ) [inline]

Definition at line 459 of file cl.hpp.

{}
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
cl::vector< T, N >::vector ( const vector< T, N > &  vec) [inline]

Definition at line 492 of file cl.hpp.

                                    : 
        size_(vec.size_),
        empty_(vec.empty_)
    {
        if (!empty_) {
            memcpy(&data_[0], &vec.data_[0], size() * sizeof(T));
        }
    } 
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
cl::vector< T, N >::vector ( unsigned int  size,
const T &  val = T() 
) [inline]

Definition at line 501 of file cl.hpp.

                                                  :
        size_(-1),
        empty_(true)
    {
        for (unsigned int i = 0; i < size; i++) {
            push_back(val);
        }
    }

Member Function Documentation

template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
template<class I >
void cl::vector< T, N >::assign ( start,
end 
) [inline]

Definition at line 568 of file cl.hpp.

    {
        clear();   
        while(start < end) {
            push_back(*start);
            start++;
        }
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
T& cl::vector< T, N >::back ( void  ) [inline]

Definition at line 675 of file cl.hpp.

    {
        return data_[size_];
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
const T& cl::vector< T, N >::back ( void  ) const [inline]

Definition at line 685 of file cl.hpp.

    {
        return data_[size_];
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
iterator cl::vector< T, N >::begin ( void  ) [inline]

Definition at line 660 of file cl.hpp.

    {
        return iterator::begin(*this);
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
unsigned int cl::vector< T, N >::capacity ( ) const [inline]

Definition at line 552 of file cl.hpp.

   {
        return sizeof(T) * N;
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
void cl::vector< T, N >::clear ( ) [inline]

Definition at line 466 of file cl.hpp.

    {
        size_ = -1;
        empty_ = true;
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
bool cl::vector< T, N >::empty ( void  ) const [inline]

Definition at line 542 of file cl.hpp.

    {
        return empty_;
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
iterator cl::vector< T, N >::end ( void  ) [inline]

Definition at line 665 of file cl.hpp.

    {
        return iterator::end(*this);
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
T& cl::vector< T, N >::front ( void  ) [inline]

Definition at line 670 of file cl.hpp.

    {
        return data_[0];
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
const T& cl::vector< T, N >::front ( void  ) const [inline]

Definition at line 680 of file cl.hpp.

    {
        return data_[0];
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
unsigned int cl::vector< T, N >::max_size ( void  ) const [inline]

Definition at line 547 of file cl.hpp.

    {
        return N;
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
cl::vector< T, N >::operator const T * ( ) const [inline]

Definition at line 540 of file cl.hpp.

{ return data_; }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
cl::vector< T, N >::operator T * ( ) [inline]

Definition at line 539 of file cl.hpp.

{ return data_; }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
vector<T, N>& cl::vector< T, N >::operator= ( const vector< T, N > &  rhs) [inline]

Definition at line 510 of file cl.hpp.

    {
        if (this == &rhs) {
            return *this;
        }

        size_  = rhs.size_;
        empty_ = rhs.empty_;

        if (!empty_) {  
            memcpy(&data_[0], &rhs.data_[0], size() * sizeof(T));
        }
    
        return *this;
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
bool cl::vector< T, N >::operator== ( vector< T, N > &  vec) [inline]

Definition at line 526 of file cl.hpp.

    {
        if (empty_ && vec.empty_) {
            return true;
        }

        if (size() != vec.size()) {
            return false;
        }

        return memcmp(&data_[0], &vec.data_[0], size() * sizeof(T)) == 0 ? true : false;
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
T& cl::vector< T, N >::operator[] ( int  index) [inline]

Definition at line 557 of file cl.hpp.

    {
        return data_[index];
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
T cl::vector< T, N >::operator[] ( int  index) const [inline]

Definition at line 562 of file cl.hpp.

    {
        return data_[index];
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
void cl::vector< T, N >::pop_back ( void  ) [inline]

Definition at line 481 of file cl.hpp.

    {
        if (!empty_) {
            data_[size_].~T();
            size_--;
            if (size_ == -1) {
                empty_ = true;
            }
        }
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
void cl::vector< T, N >::push_back ( const T &  x) [inline]

Definition at line 472 of file cl.hpp.

    { 
        if (size() < N) {
            size_++;  
            data_[size_] = x;
            empty_ = false;
        }
    }
template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
unsigned int cl::vector< T, N >::size ( void  ) const [inline]

Definition at line 461 of file cl.hpp.

    {
        return size_ + 1;
    }

Member Data Documentation

template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
T cl::vector< T, N >::data_[N] [private]

Definition at line 450 of file cl.hpp.

template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
bool cl::vector< T, N >::empty_ [private]

Definition at line 452 of file cl.hpp.

template<typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE>
unsigned int cl::vector< T, N >::size_ [private]

Definition at line 451 of file cl.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Defines