cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Vector< T > Class Template Reference

#include <CCVector.h>

Public Types

typedef std::vector< T >::iterator iterator
 Iterator, can be used to loop the Vector. More...
 
typedef std::vector< T >
::const_iterator 
const_iterator
 Const iterator, can be used to loop the Vector. More...
 
typedef std::vector< T >
::reverse_iterator 
reverse_iterator
 Reversed iterator, can be used to loop the Vector in reverse sequence. More...
 
typedef std::vector< T >
::const_reverse_iterator 
const_reverse_iterator
 Reversed iterator, can be used to loop the Vector in reverse sequence. More...
 

Public Member Functions

iterator begin ()
 Returns an iterator pointing the first element of the Vector. More...
 
var begin ()
 Returns an iterator pointing the first element of the Vector. More...
 
const_iterator begin () const
 Returns an iterator pointing the first element of the Vector. More...
 
var begin ()
 Returns an iterator pointing the first element of the Vector. More...
 
iterator end ()
 Returns an iterator referring to the past-the-end element in the Vector container. More...
 
const_iterator end () const
 Returns iterator referring to the past-the-end element in the Vector container. More...
 
const_iterator cbegin () const
 Returns a const_iterator pointing the first element of the Vector. More...
 
const_iterator cend () const
 Returns a const_iterator pointing the past-the-end element of the Vector. More...
 
var cend ()
 Returns a const_iterator pointing the past-the-end element of the Vector. More...
 
reverse_iterator rbegin ()
 Returns a reverse iterator pointing to the last element of the Vector. More...
 
const_reverse_iterator rbegin () const
 Returns a reverse iterator pointing to the last element of the Vector. More...
 
reverse_iterator rend ()
 Returns a reverse iterator pointing to the theoretical element preceding the first element of the vector (which is considered its reverse end). More...
 
const_reverse_iterator rend () const
 Returns a reverse iterator pointing to the theoretical element preceding the first element of the vector (which is considered its reverse end). More...
 
const_reverse_iterator crbegin () const
 Returns a const_reverse_iterator pointing to the last element in the container (i.e., its reverse beginning). More...
 
const_reverse_iterator crend () const
 Returns a const_reverse_iterator pointing to the theoretical element preceding the first element in the container (which is considered its reverse end). More...
 
 Vector ()
 Constructor. More...
 
 Vector ()
 Constructor. More...
 
 Vector (ssize_t capacity)
 Constructor with a capacity. More...
 
 Vector ( var capacity)
 Constructor with a capacity. More...
 
 ~Vector ()
 Destructor. More...
 
 ~Vector ()
 Destructor. More...
 
 Vector (const Vector< T > &other)
 Copy constructor. More...
 
 Vector ( var other)
 Copy constructor. More...
 
 Vector (Vector< T > &&other)
 Constructor with std::move semantic. More...
 
Vector< T > & operator= (const Vector< T > &other)
 Copy assignment operator. More...
 
var operator= ( var other)
 Copy assignment operator. More...
 
Vector< T > & operator= (Vector< T > &&other)
 Copy assignment operator with std::move semantic. More...
 
var operator= ( var other)
 Copy assignment operator with std::move semantic. More...
 
void reserve (ssize_t n)
 Requests that the vector capacity be at least enough to contain n elements. More...
 
ssize_t capacity () const
 Returns the size of the storage space currently allocated for the Vector, expressed in terms of elements. More...
 
ssize_t size () const
 Returns the number of elements in the Vector. More...
 
bool empty () const
 Returns whether the Vector is empty (i.e. More...
 
var empty ()
 Returns whether the Vector is empty (i.e. More...
 
ssize_t max_size () const
 Returns the maximum number of elements that the Vector can hold. More...
 
ssize_t getIndex (T object) const
 Returns index of a certain object, return UINT_MAX if doesn't contain the object. More...
 
var getIndex ( var object)
 Returns index of a certain object, return UINT_MAX if doesn't contain the object. More...
 
const_iterator find (T object) const
 Find the object in the Vector. More...
 
iterator find (T object)
 Find the object in the Vector. More...
 
var find ( var object)
 Find the object in the Vector. More...
 
at (ssize_t index) const
 Returns the element at position 'index' in the Vector. More...
 
var at ( var index)
 Returns the element at position 'index' in the Vector. More...
 
front () const
 Returns the first element in the Vector. More...
 
var front ()
 Returns the first element in the Vector. More...
 
back () const
 Returns the last element of the Vector. More...
 
var back ()
 Returns the last element of the Vector. More...
 
getRandomObject () const
 Returns a random element of the Vector. More...
 
var getRandomObject ()
 Returns a random element of the Vector. More...
 
bool contains (T object) const
 Checks whether an object is in the container. More...
 
var contains ( var object)
 Checks whether an object is in the container. More...
 
bool equals (const Vector< T > &other)
 Checks whether two vectors are equal. More...
 
void pushBack (T object)
 Adds a new element at the end of the Vector. More...
 
void pushBack (const Vector< T > &other)
 Push all elements of an existing Vector to the end of current Vector. More...
 
void insert (ssize_t index, T object)
 Insert an object at certain index. More...
 
var insert ( var index, var object)
 Insert an object at certain index. More...
 
void popBack ()
 Removes the last element in the Vector. More...
 
var popBack ()
 Removes the last element in the Vector. More...
 
void eraseObject (T object, bool removeAll=false)
 Remove a certain object in Vector. More...
 
iterator erase (iterator position)
 Removes from the vector with an iterator. More...
 
iterator erase (iterator first, iterator last)
 Removes from the Vector with a range of elements ( [first, last) ). More...
 
iterator erase (ssize_t index)
 Removes from the Vector by index. More...
 
var erase ( var index)
 Removes from the Vector by index. More...
 
void clear ()
 Removes all elements from the Vector (which are destroyed), leaving the container with a size of 0. More...
 
void swap (T object1, T object2)
 Swap the values object1 and object2. More...
 
var swap ( var object1, var object2)
 Swap the values object1 and object2. More...
 
void swap (ssize_t index1, ssize_t index2)
 Swap two elements by indexes. More...
 
var swap ( var index1, var index2)
 Swap two elements by indexes. More...
 
void replace (ssize_t index, T object)
 Replace value at index with given object. More...
 
var replace ( var index, var object)
 Replace value at index with given object. More...
 
void reverse ()
 Reverses the Vector. More...
 
void shrinkToFit ()
 Requests the container to reduce its capacity to fit its size. More...
 
var shrinkToFit ()
 Requests the container to reduce its capacity to fit its size. More...
 

Protected Member Functions

void addRefForAllObjects ()
 Retains all the objects in the vector. More...
 
var addRefForAllObjects ()
 Retains all the objects in the vector. More...
 

Protected Attributes

std::vector< T > _data

Member Typedef Documentation

typedef std::vector<T>
::const_iterator
const_iterator

Const iterator, can be used to loop the Vector.

Const iterator, can be used to loop the Vector.

Reversed iterator, can be used to loop the Vector in reverse sequence.

Reversed iterator, can be used to loop the Vector in reverse sequence.

typedef std::vector<T>
::iterator iterator

Iterator, can be used to loop the Vector.

var iterator

Iterator, can be used to loop the Vector.

typedef std::vector<T>
::reverse_iterator
reverse_iterator

Reversed iterator, can be used to loop the Vector in reverse sequence.

Reversed iterator, can be used to loop the Vector in reverse sequence.

Constructor & Destructor Documentation

Vector ( )
inline

Constructor.

var Vector ( )
inline

Constructor.

Vector ( ssize_t  capacity)
inlineexplicit

Constructor with a capacity.

Parameters
capacityCapacity of the Vector.
var Vector ( var  capacity)
inlineexplicit

Constructor with a capacity.

Parameters
capacityCapacity of the Vector.
~Vector ( )
inline

Destructor.

var ~Vector ( )
inline

Destructor.

Vector ( const Vector< T > &  other)
inline

Copy constructor.

var Vector ( var  other)
inline

Copy constructor.

Vector ( Vector< T > &&  other)
inline

Constructor with std::move semantic.

var Vector ( var  other)
inline

Constructor with std::move semantic.

Member Function Documentation

void addRefForAllObjects ( )
inlineprotected

Retains all the objects in the vector.

var addRefForAllObjects ( )
inlineprotected

Retains all the objects in the vector.

T at ( ssize_t  index) const
inline

Returns the element at position 'index' in the Vector.

var at ( var  index)
inline

Returns the element at position 'index' in the Vector.

T back ( ) const
inline

Returns the last element of the Vector.

var back ( )
inline

Returns the last element of the Vector.

iterator begin ( )
inline

Returns an iterator pointing the first element of the Vector.

var begin ( )
inline

Returns an iterator pointing the first element of the Vector.

const_iterator begin ( ) const
inline

Returns an iterator pointing the first element of the Vector.

var begin ( )
inline

Returns an iterator pointing the first element of the Vector.

ssize_t capacity ( ) const
inline

Returns the size of the storage space currently allocated for the Vector, expressed in terms of elements.

Note
This capacity is not necessarily equal to the Vector size. It can be equal or greater, with the extra space allowing to accommodate for growth without the need to reallocate on each insertion.
Returns
The size of the currently allocated storage capacity in the Vector, measured in terms of the number elements it can hold.
var capacity ( )
inline

Returns the size of the storage space currently allocated for the Vector, expressed in terms of elements.

Note
This capacity is not necessarily equal to the Vector size. It can be equal or greater, with the extra space allowing to accommodate for growth without the need to reallocate on each insertion.
Returns
The size of the currently allocated storage capacity in the Vector, measured in terms of the number elements it can hold.
const_iterator cbegin ( ) const
inline

Returns a const_iterator pointing the first element of the Vector.

var cbegin ( )
inline

Returns a const_iterator pointing the first element of the Vector.

const_iterator cend ( ) const
inline

Returns a const_iterator pointing the past-the-end element of the Vector.

var cend ( )
inline

Returns a const_iterator pointing the past-the-end element of the Vector.

void clear ( )
inline

Removes all elements from the Vector (which are destroyed), leaving the container with a size of 0.

Note
All the elements in the Vector will be released (referece count will be decreased).
var clear ( )
inline

Removes all elements from the Vector (which are destroyed), leaving the container with a size of 0.

Note
All the elements in the Vector will be released (referece count will be decreased).
bool contains ( object) const
inline

Checks whether an object is in the container.

Parameters
objectThe object to be checked.
Returns
True if the object is in the container, false if not.
var contains ( var  object)
inline

Checks whether an object is in the container.

Parameters
objectThe object to be checked.
Returns
True if the object is in the container, false if not.
const_reverse_iterator crbegin ( ) const
inline

Returns a const_reverse_iterator pointing to the last element in the container (i.e., its reverse beginning).

var crbegin ( )
inline

Returns a const_reverse_iterator pointing to the last element in the container (i.e., its reverse beginning).

const_reverse_iterator crend ( ) const
inline

Returns a const_reverse_iterator pointing to the theoretical element preceding the first element in the container (which is considered its reverse end).

var crend ( )
inline

Returns a const_reverse_iterator pointing to the theoretical element preceding the first element in the container (which is considered its reverse end).

bool empty ( ) const
inline

Returns whether the Vector is empty (i.e.

whether its size is 0).

Note
This function does not modify the container in any way. To clear the content of a vector, see Vector<T>::clear.
var empty ( )
inline

Returns whether the Vector is empty (i.e.

whether its size is 0).

Note
This function does not modify the container in any way. To clear the content of a vector, see Vector<T>::clear.
iterator end ( )
inline

Returns an iterator referring to the past-the-end element in the Vector container.

The past-the-end element is the theoretical element that would follow the last element in the Vector. It does not point to any element, and thus shall not be dereferenced.

var end ( )
inline

Returns an iterator referring to the past-the-end element in the Vector container.

The past-the-end element is the theoretical element that would follow the last element in the Vector. It does not point to any element, and thus shall not be dereferenced.

const_iterator end ( ) const
inline

Returns iterator referring to the past-the-end element in the Vector container.

The past-the-end element is the theoretical element that would follow the last element in the Vector. It does not point to any element, and thus shall not be dereferenced.

var end ( )
inline

Returns iterator referring to the past-the-end element in the Vector container.

The past-the-end element is the theoretical element that would follow the last element in the Vector. It does not point to any element, and thus shall not be dereferenced.

bool equals ( const Vector< T > &  other)
inline

Checks whether two vectors are equal.

Parameters
otherThe vector to be compared.
Returns
True if two vectors are equal, false if not.
var equals ( var  other)
inline

Checks whether two vectors are equal.

Parameters
otherThe vector to be compared.
Returns
True if two vectors are equal, false if not.
iterator erase ( iterator  position)
inline

Removes from the vector with an iterator.

Parameters
positionIterator pointing to a single element to be removed from the Vector.
Returns
An iterator pointing to the new location of the element that followed the last element erased by the function call. This is the container end if the operation erased the last element in the sequence.
var erase ( var  position)
inline

Removes from the vector with an iterator.

Parameters
positionIterator pointing to a single element to be removed from the Vector.
Returns
An iterator pointing to the new location of the element that followed the last element erased by the function call. This is the container end if the operation erased the last element in the sequence.
iterator erase ( iterator  first,
iterator  last 
)
inline

Removes from the Vector with a range of elements ( [first, last) ).

Parameters
firstThe beginning of the range.
lastThe end of the range, the 'last' will not be removed, it's only for indicating the end of range.
Returns
An iterator pointing to the new location of the element that followed the last element erased by the function call. This is the container end if the operation erased the last element in the sequence.
var erase ( var  first,
var  last 
)
inline

Removes from the Vector with a range of elements ( [first, last) ).

Parameters
firstThe beginning of the range.
lastThe end of the range, the 'last' will not be removed, it's only for indicating the end of range.
Returns
An iterator pointing to the new location of the element that followed the last element erased by the function call. This is the container end if the operation erased the last element in the sequence.
iterator erase ( ssize_t  index)
inline

Removes from the Vector by index.

Parameters
indexThe index of the element to be removed from the Vector.
Returns
An iterator pointing to the successor of Vector[index].
var erase ( var  index)
inline

Removes from the Vector by index.

Parameters
indexThe index of the element to be removed from the Vector.
Returns
An iterator pointing to the successor of Vector[index].
void eraseObject ( object,
bool  removeAll = false 
)
inline

Remove a certain object in Vector.

Parameters
objectThe object to be removed.
removeAllWhether to remove all elements with the same value. If its value is 'false', it will just erase the first occurrence.
var eraseObject ( var  object,
var  removeAll = false 
)
inline

Remove a certain object in Vector.

Parameters
objectThe object to be removed.
removeAllWhether to remove all elements with the same value. If its value is 'false', it will just erase the first occurrence.
const_iterator find ( object) const
inline

Find the object in the Vector.

Parameters
objectThe object to find.
Returns
Returns an iterator which refers to the element that its value is equals to object. Returns Vector::end() if not found.
var find ( var  object)
inline

Find the object in the Vector.

Parameters
objectThe object to find.
Returns
Returns an iterator which refers to the element that its value is equals to object. Returns Vector::end() if not found.
iterator find ( object)
inline

Find the object in the Vector.

Parameters
objectThe object to find.
Returns
Returns an iterator which refers to the element that its value is equals to object. Returns Vector::end() if not found.
var find ( var  object)
inline

Find the object in the Vector.

Parameters
objectThe object to find.
Returns
Returns an iterator which refers to the element that its value is equals to object. Returns Vector::end() if not found.
T front ( ) const
inline

Returns the first element in the Vector.

var front ( )
inline

Returns the first element in the Vector.

ssize_t getIndex ( object) const
inline

Returns index of a certain object, return UINT_MAX if doesn't contain the object.

var getIndex ( var  object)
inline

Returns index of a certain object, return UINT_MAX if doesn't contain the object.

T getRandomObject ( ) const
inline

Returns a random element of the Vector.

var getRandomObject ( )
inline

Returns a random element of the Vector.

void insert ( ssize_t  index,
object 
)
inline

Insert an object at certain index.

Parameters
indexThe index to be inserted at.
objectThe object to be inserted.
var insert ( var  index,
var  object 
)
inline

Insert an object at certain index.

Parameters
indexThe index to be inserted at.
objectThe object to be inserted.
ssize_t max_size ( ) const
inline

Returns the maximum number of elements that the Vector can hold.

var max_size ( )
inline

Returns the maximum number of elements that the Vector can hold.

Vector<T>& operator= ( const Vector< T > &  other)
inline

Copy assignment operator.

Vector<T>& operator= ( var  other)
inline

Copy assignment operator.

Vector<T>& operator= ( Vector< T > &&  other)
inline

Copy assignment operator with std::move semantic.

Vector<T>& operator= ( var  other)
inline

Copy assignment operator with std::move semantic.

void popBack ( )
inline

Removes the last element in the Vector.

var popBack ( )
inline

Removes the last element in the Vector.

void pushBack ( object)
inline

Adds a new element at the end of the Vector.

var pushBack ( var  object)
inline

Adds a new element at the end of the Vector.

void pushBack ( const Vector< T > &  other)
inline

Push all elements of an existing Vector to the end of current Vector.

var pushBack ( var  other)
inline

Push all elements of an existing Vector to the end of current Vector.

reverse_iterator rbegin ( )
inline

Returns a reverse iterator pointing to the last element of the Vector.

var rbegin ( )
inline

Returns a reverse iterator pointing to the last element of the Vector.

const_reverse_iterator rbegin ( ) const
inline

Returns a reverse iterator pointing to the last element of the Vector.

var rbegin ( )
inline

Returns a reverse iterator pointing to the last element of the Vector.

reverse_iterator rend ( )
inline

Returns a reverse iterator pointing to the theoretical element preceding the first element of the vector (which is considered its reverse end).

var rend ( )
inline

Returns a reverse iterator pointing to the theoretical element preceding the first element of the vector (which is considered its reverse end).

const_reverse_iterator rend ( ) const
inline

Returns a reverse iterator pointing to the theoretical element preceding the first element of the vector (which is considered its reverse end).

var rend ( )
inline

Returns a reverse iterator pointing to the theoretical element preceding the first element of the vector (which is considered its reverse end).

void replace ( ssize_t  index,
object 
)
inline

Replace value at index with given object.

var replace ( var  index,
var  object 
)
inline

Replace value at index with given object.

void reserve ( ssize_t  n)
inline

Requests that the vector capacity be at least enough to contain n elements.

Parameters
capacityMinimum capacity requested of the Vector.
var reserve ( var  n)
inline

Requests that the vector capacity be at least enough to contain n elements.

Parameters
capacityMinimum capacity requested of the Vector.
void reverse ( void  )
inline

Reverses the Vector.

var reverse (   )
inline

Reverses the Vector.

void shrinkToFit ( )
inline

Requests the container to reduce its capacity to fit its size.

var shrinkToFit ( )
inline

Requests the container to reduce its capacity to fit its size.

ssize_t size ( ) const
inline

Returns the number of elements in the Vector.

Note
This is the number of actual objects held in the Vector, which is not necessarily equal to its storage capacity.
Returns
The number of elements in the Vector.
var size ( )
inline

Returns the number of elements in the Vector.

Note
This is the number of actual objects held in the Vector, which is not necessarily equal to its storage capacity.
Returns
The number of elements in the Vector.
void swap ( object1,
object2 
)
inline

Swap the values object1 and object2.

var swap ( var  object1,
var  object2 
)
inline

Swap the values object1 and object2.

void swap ( ssize_t  index1,
ssize_t  index2 
)
inline

Swap two elements by indexes.

var swap ( var  index1,
var  index2 
)
inline

Swap two elements by indexes.

Member Data Documentation

std::vector<T> _data
protected
var _data
protected

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