cocos2d-x  3.0
 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
typedef std::vector< T >
::const_iterator 
const_iterator
typedef std::vector< T >
::reverse_iterator 
reverse_iterator
typedef std::vector< T >
::const_reverse_iterator 
const_reverse_iterator

Public Member Functions

iterator begin ()
local begin ()
const_iterator begin () const
local begin ()
iterator end ()
var end ()
local end ()
const_iterator end () const
local end ()
const_iterator cbegin () const
local cbegin ()
const_iterator cend () const
local cend ()
reverse_iterator rbegin ()
local rbegin ()
const_reverse_iterator rbegin () const
local rbegin ()
reverse_iterator rend ()
var rend ()
local rend ()
const_reverse_iterator rend () const
local rend ()
const_reverse_iterator crbegin () const
local crbegin ()
const_reverse_iterator crend () const
local crend ()
 Vector ()
 Constructor. 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 ( local capacity)
 Constructor with a capacity. More...
 
 ~Vector ()
 Destructor. More...
 
 Vector (const Vector< T > &other)
 Copy constructor. More...
 
 Vector ( var other)
 Copy constructor. More...
 
 Vector ( local other)
 Copy constructor. More...
 
 Vector (Vector< T > &&other)
 Move constructor. More...
 
Vector< T > & operator= (const Vector< T > &other)
 Copy assignment operator. More...
 
var operator= ( var other)
 Copy assignment operator. More...
 
local operator= ( local other)
 Copy assignment operator. More...
 
Vector< T > & operator= (Vector< T > &&other)
 Move assignment operator. More...
 
var operator= ( var other)
 Move assignment operator. More...
 
local operator= ( local other)
 Move assignment operator. More...
 
void reserve (ssize_t n)
 Request a change in capacity. More...
 
var reserve ( var n)
 Request a change in capacity. More...
 
local reserve ( local n)
 Request a change in capacity. 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...
 
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...
 
local getIndex ( local 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...
 
var find ( var object)
 Find the object in the vector. More...
 
local find ( local object)
 Find the object in the vector. More...
 
iterator find (T object)
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...
 
local at ( local index)
 Returns the element at position 'index' in the vector. More...
 
front () const
 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...
 
local 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...
 
local getRandomObject ()
 Returns a random element of the vector. More...
 
bool contains (T object) const
 Returns a Boolean value that indicates whether object is present in vector. More...
 
var contains ( var object)
 Returns a Boolean value that indicates whether object is present in vector. More...
 
local contains ( local object)
 Returns a Boolean value that indicates whether object is present in vector. More...
 
bool equals (const Vector< T > &other)
 Returns true if the two vectors are equal. More...
 
var equals ( var other)
 Returns true if the two vectors are equal. More...
 
local equals ( local other)
 Returns true if the two vectors are equal. More...
 
void pushBack (T object)
 Adds a new element at the end of the vector, after its current last element. 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 a certain object at a certain index. More...
 
void popBack ()
 Removes the last element in the vector, effectively reducing the container size by one, decrease the referece count of the deleted object. More...
 
var popBack ()
 Removes the last element in the vector, effectively reducing the container size by one, decrease the referece count of the deleted object. More...
 
local popBack ()
 Removes the last element in the vector, effectively reducing the container size by one, decrease the referece count of the deleted object. 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 with an 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 two elements. More...
 
void swap (ssize_t index1, ssize_t index2)
 Swap two elements with certain indexes. More...
 
void replace (ssize_t index, T object)
 Replace object at index with another object. More...
 
var replace ( var index, var object)
 Replace object at index with another object. More...
 
local replace ( local index, local object)
 Replace object at index with another object. More...
 
void reverse ()
 reverses the vector More...
 
var reverse ()
 reverses the vector More...
 
local reverse ()
 reverses the vector More...
 
void shrinkToFit ()
 Shrinks the vector so the memory footprint corresponds with the number of items. More...
 

Protected Member Functions

void addRefForAllObjects ()
 Retains all the objects in the vector. More...
 
local 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
typedef std::vector<T>
::iterator iterator
var iterator
local iterator
typedef std::vector<T>
::reverse_iterator
reverse_iterator

Constructor & Destructor Documentation

Vector ( )
inline

Constructor.

var Vector ( )
inline

Constructor.

local Vector ( )
inline

Constructor.

Vector ( ssize_t  capacity)
inlineexplicit

Constructor with a capacity.

var Vector ( var  capacity)
inlineexplicit

Constructor with a capacity.

local Vector ( local  capacity)
inlineexplicit

Constructor with a capacity.

~Vector ( )
inline

Destructor.

var ~Vector ( )
inline

Destructor.

local ~Vector ( )
inline

Destructor.

Vector ( const Vector< T > &  other)
inline

Copy constructor.

var Vector ( var  other)
inline

Copy constructor.

local Vector ( local  other)
inline

Copy constructor.

Vector ( Vector< T > &&  other)
inline

Move constructor.

var Vector ( var  other)
inline

Move constructor.

local Vector ( local  other)
inline

Move constructor.

Member Function Documentation

void addRefForAllObjects ( )
inlineprotected

Retains all the objects in the vector.

var addRefForAllObjects ( )
inlineprotected

Retains all the objects in the vector.

local 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.

local at ( local  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.

local back ( )
inline

Returns the last element of the vector.

iterator begin ( )
inline
var begin ( )
inline
local begin ( )
inline
const_iterator begin ( ) const
inline
var begin ( )
inline
local begin ( )
inline
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.
local 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
var cbegin ( )
inline
local cbegin ( )
inline
const_iterator cend ( ) const
inline
var cend ( )
inline
local cend ( )
inline
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).
local 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

Returns a Boolean value that indicates whether object is present in vector.

var contains ( var  object)
inline

Returns a Boolean value that indicates whether object is present in vector.

local contains ( local  object)
inline

Returns a Boolean value that indicates whether object is present in vector.

const_reverse_iterator crbegin ( ) const
inline
var crbegin ( )
inline
local crbegin ( )
inline
const_reverse_iterator crend ( ) const
inline
var crend ( )
inline
local crend ( )
inline
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.
local 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
var end ( )
inline
local end ( )
inline
const_iterator end ( ) const
inline
var end ( )
inline
local end ( )
inline
bool equals ( const Vector< T > &  other)
inline

Returns true if the two vectors are equal.

var equals ( var  other)
inline

Returns true if the two vectors are equal.

local equals ( local  other)
inline

Returns true if the two vectors are equal.

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.
local erase ( local  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 used, 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 used, 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.
local erase ( local  first,
local  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 used, 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 with an index.

Parameters
indexThe index of the 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  index)
inline

Removes from the vector with an index.

Parameters
indexThe index of the 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.
local erase ( local  index)
inline

Removes from the vector with an index.

Parameters
indexThe index of the 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.
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.
local eraseObject ( local  object,
local  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.

Returns
Returns an iterator to the first element in the range [first,last) that compares equal to val. If no such element is found, the function returns last.
var find ( var  object)
inline

Find the object in the vector.

Returns
Returns an iterator to the first element in the range [first,last) that compares equal to val. If no such element is found, the function returns last.
local find ( local  object)
inline

Find the object in the vector.

Returns
Returns an iterator to the first element in the range [first,last) that compares equal to val. If no such element is found, the function returns last.
iterator find ( object)
inline
var find ( var  object)
inline
local find ( local  object)
inline
T front ( ) const
inline

Returns the first element in the vector.

var front ( )
inline

Returns the first element in the vector.

local 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.

local getIndex ( local  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.

local getRandomObject ( )
inline

Returns a random element of the vector.

void insert ( ssize_t  index,
object 
)
inline

Insert a certain object at a certain index.

Note
The vector is extended by inserting new elements before the element at the specified 'index', effectively increasing the container size by the number of elements inserted. This causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity.
var insert ( var  index,
var  object 
)
inline

Insert a certain object at a certain index.

Note
The vector is extended by inserting new elements before the element at the specified 'index', effectively increasing the container size by the number of elements inserted. This causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity.
local insert ( local  index,
local  object 
)
inline

Insert a certain object at a certain index.

Note
The vector is extended by inserting new elements before the element at the specified 'index', effectively increasing the container size by the number of elements inserted. This causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity.
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.

local 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= ( local  other)
inline

Copy assignment operator.

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

Move assignment operator.

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

Move assignment operator.

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

Move assignment operator.

void popBack ( )
inline

Removes the last element in the vector, effectively reducing the container size by one, decrease the referece count of the deleted object.

var popBack ( )
inline

Removes the last element in the vector, effectively reducing the container size by one, decrease the referece count of the deleted object.

local popBack ( )
inline

Removes the last element in the vector, effectively reducing the container size by one, decrease the referece count of the deleted object.

void pushBack ( object)
inline

Adds a new element at the end of the vector, after its current last element.

Note
This effectively increases the container size by one, which causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity.
var pushBack ( var  object)
inline

Adds a new element at the end of the vector, after its current last element.

Note
This effectively increases the container size by one, which causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity.
local pushBack ( local  object)
inline

Adds a new element at the end of the vector, after its current last element.

Note
This effectively increases the container size by one, which causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity.
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.

local pushBack ( local  other)
inline

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

reverse_iterator rbegin ( )
inline
var rbegin ( )
inline
local rbegin ( )
inline
const_reverse_iterator rbegin ( ) const
inline
var rbegin ( )
inline
local rbegin ( )
inline
reverse_iterator rend ( )
inline
var rend ( )
inline
local rend ( )
inline
const_reverse_iterator rend ( ) const
inline
var rend ( )
inline
local rend ( )
inline
void replace ( ssize_t  index,
object 
)
inline

Replace object at index with another object.

var replace ( var  index,
var  object 
)
inline

Replace object at index with another object.

local replace ( local  index,
local  object 
)
inline

Replace object at index with another object.

void reserve ( ssize_t  n)
inline

Request a change in capacity.

Parameters
capacityMinimum capacity for the vector. If n is greater than the current vector capacity, the function causes the container to reallocate its storage increasing its capacity to n (or greater).
var reserve ( var  n)
inline

Request a change in capacity.

Parameters
capacityMinimum capacity for the vector. If n is greater than the current vector capacity, the function causes the container to reallocate its storage increasing its capacity to n (or greater).
local reserve ( local  n)
inline

Request a change in capacity.

Parameters
capacityMinimum capacity for the vector. If n is greater than the current vector capacity, the function causes the container to reallocate its storage increasing its capacity to n (or greater).
void reverse ( void  )
inline

reverses the vector

var reverse (   )
inline

reverses the vector

local reverse (   )
inline

reverses the vector

void shrinkToFit ( )
inline

Shrinks the vector so the memory footprint corresponds with the number of items.

var shrinkToFit ( )
inline

Shrinks the vector so the memory footprint corresponds with the number of items.

local shrinkToFit ( )
inline

Shrinks the vector so the memory footprint corresponds with the number of items.

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 container.
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 container.
local 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 container.
void swap ( object1,
object2 
)
inline

Swap two elements.

var swap ( var  object1,
var  object2 
)
inline

Swap two elements.

local swap ( local  object1,
local  object2 
)
inline

Swap two elements.

void swap ( ssize_t  index1,
ssize_t  index2 
)
inline

Swap two elements with certain indexes.

var swap ( var  index1,
var  index2 
)
inline

Swap two elements with certain indexes.

local swap ( local  index1,
local  index2 
)
inline

Swap two elements with certain indexes.

Member Data Documentation

std::vector<T> _data
protected

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