cocos2d-x 3.0
- 首页 - 相关页面 - 模块 - 命名空间 - - 文件 -
Public 类型 - 图1 Public 类型 - 图2)
- 类列表 - 类索引 - 类继承关系 - 类成员

全部)) 命名空间) 文件) 函数) 变量) 类型定义) 枚举) 枚举值) 属性) 友元) 宏定义)))

Public 类型 | Public 成员函数 | Protected 成员函数 | Protected 属性 | 所有成员列表

Vector< T > 模板类 参考

#include

## Public 类型
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 成员函数
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
const_iterator cbegin () const
const_iterator cend () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const
const_reverse_iterator crbegin () const
const_reverse_iterator crend () const
Vector ()
Constructor. 更多…
Vector (ssize_t capacity)
Constructor with a capacity. 更多…
~Vector ()
Destructor. 更多…
Vector (const Vector< T > &other)
Copy constructor. 更多…
Vector (Vector< T > &&other)
Move constructor. 更多…
Vector< T > & operator= (const Vector< T > &other)
Copy assignment operator. 更多…
Vector< T > & operator= (Vector< T > &&other)
Move assignment operator. 更多…
void reserve (ssize_t n)
Request a change in capacity. 更多…
ssize_t capacity () const
Returns the size of the storage space currently allocated for the vector, expressed in terms of elements. 更多…
ssize_t size () const
Returns the number of elements in the vector. 更多…
bool empty () const
Returns whether the vector is empty (i.e. 更多…
ssize_t max_size () const
Returns the maximum number of elements that the vector can hold. 更多…
ssize_t getIndex (T object) const
Returns index of a certain object, return UINT_MAX if doesn't contain the object. 更多…
const_iterator find (T object) const
Find the object in the vector. 更多…
iterator find (T object)
T at (ssize_t index) const
Returns the element at position 'index' in the vector. 更多…
T front () const
Returns the first element in the vector. 更多…
T back () const
Returns the last element of the vector. 更多…
T getRandomObject () const
Returns a random element of the vector. 更多…
bool contains (T object) const
Returns a Boolean value that indicates whether object is present in vector. 更多…
bool equals (const Vector< T > &other)
Returns true if the two vectors are equal. 更多…
void pushBack (T object)
Adds a new element at the end of the vector, after its current last element. 更多…
void pushBack (const Vector< T > &other)
Push all elements of an existing vector to the end of current vector. 更多…
void insert (ssize_t index, T object)
Insert a certain object at a certain index. 更多…
void popBack ()
Removes the last element in the vector, effectively reducing the container size by one, decrease the referece count of the deleted object. 更多…
void eraseObject (T object, bool removeAll=false)
Remove a certain object in Vector. 更多…
iterator erase (iterator position)
Removes from the vector with an iterator. 更多…
iterator erase (iterator first, iterator last)
Removes from the vector with a range of elements ( [first, last) ). 更多…
iterator erase (ssize_t index)
Removes from the vector with an index. 更多…
void clear ()
Removes all elements from the vector (which are destroyed), leaving the container with a size of 0. 更多…
void swap (T object1, T object2)
Swap two elements. 更多…
void swap (ssize_t index1, ssize_t index2)
Swap two elements with certain indexes. 更多…
void replace (ssize_t index, T object)
Replace object at index with another object. 更多…
void reverse ()
reverses the vector 更多…
void shrinkToFit ()
Shrinks the vector so the memory footprint corresponds with the number of items. 更多…
## Protected 成员函数
void addRefForAllObjects ()
Retains all the objects in the vector. 更多…
## Protected 属性
std::vector< T > _data

成员类型定义说明

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

typedef std::vector<T>::const_reverse_iterator const_reverse_iterator

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

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

构造及析构函数说明

Vector ( )

inline

Constructor.

Vector ( ssize_t capacity)

inlineexplicit

Constructor with a capacity.

~Vector ( )

inline

Destructor.

Vector ( const Vector< T > & other)

inline

Copy constructor.

Vector ( Vector< T > && other)

inline

Move constructor.

成员函数说明

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

T back ( ) const

inline

Returns the last element of the vector.

iterator begin ( )

inline

const_iterator begin ( ) const

inline

ssize_t capacity ( ) const

inline

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

  • 注解
  • 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.
  • 返回
  • 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

const_iterator cend ( ) const

inline

void clear ( )

inline

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

  • 注解
  • All the elements in the vector will be released (referece count will be decreased).

bool contains ( T object) const

inline

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

const_reverse_iterator crbegin ( ) const

inline

const_reverse_iterator crend ( ) const

inline

bool empty ( ) const

inline

Returns whether the vector is empty (i.e.

whether its size is 0).

  • 注解
  • This function does not modify the container in any way. To clear the content of a vector, see Vector::clear.

iterator end ( )

inline

const_iterator end ( ) const

inline

bool equals ( const Vector< T > & other)

inline

Returns true if the two vectors are equal.

iterator erase ( iterator position)

inline

Removes from the vector with an iterator.

  • 参数
  • positionIterator pointing to a single element to be removed from the vector.

  • 返回
  • 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) ).

  • 参数
  • firstThe beginning of the range lastThe end of the range, the 'last' will not used, it's only for indicating the end of range.

  • 返回
  • 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.

  • 参数
  • indexThe index of the element to be removed from the vector.

  • 返回
  • 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 ( T object,
bool removeAll = false
)

inline

Remove a certain object in Vector.

  • 参数
  • 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 ( T object) const

inline

Find the object in the vector.

  • 返回
  • 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 ( T object)

inline

T front ( ) const

inline

Returns the first element in the vector.

ssize_t getIndex ( T object) const

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.

void insert ( ssize_t index,
T object
)

inline

Insert a certain object at a certain index.

  • 注解
  • 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.

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

inline

Copy assignment operator.

Vector<T>& operator= ( Vector< T > && 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.

void pushBack ( T object)

inline

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

  • 注解
  • 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.

reverse_iterator rbegin ( )

inline

const_reverse_iterator rbegin ( ) const

inline

reverse_iterator rend ( )

inline

const_reverse_iterator rend ( ) const

inline

void replace ( ssize_t index,
T object
)

inline

Replace object at index with another object.

void reserve ( ssize_t n)

inline

Request a change in capacity.

  • 参数
  • 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

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

  • 注解
  • This is the number of actual objects held in the vector, which is not necessarily equal to its storage capacity.
  • 返回
  • The number of elements in the container.

void swap ( T object1,
T object2
)

inline

Swap two elements.

void swap ( ssize_t index1,
ssize_t index2
)

inline

Swap two elements with certain indexes.

类成员变量说明

std::vector<T> _data

protected


该类的文档由以下文件生成:

  • /Users/zeroyang/Documents/github/cocos2d-x/cocos/base/CCVector.h
  • cocos2d
  • Vector
  • 生成于 2014年 五月 29日 星期四 09:41:53 , 为 cocos2d-x使用 doxygen 1.8.6