// returns true if the two vectors are equal
Vector<Sprite*> vec2(*vec0);
if (vec0->equals(vec2)) { ... }
// whether the Vector is empty
if(!vec1.empty()) { ... }
// shrinks the vector so the memory footprint corresponds with the number of items
vec1.shrinkToFit();
// checks whether an object is in the container.
vec1.contains(sprite0);
// returns the number of elements in the Vector
vec1.size()
// the size of the currently allocated storage capacity in the Vector, measured in terms of the number elements it can hold.
// 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.
vec1.capacity()
for (auto bullet: this->_bullets)
{
if (bullet->getPositionX() > 160)
{
// ...
}
}
// add an object
auto sprite1 = Sprite::create();
this->vec1.pushBack(sprite1);
// insert a certain object at a certain index
auto sprite1 = Sprite::create();
vec1.insert(0, sprite1);
// we can also add a whole vector
vec1.pushBack(*vec0);
// remove the element from the Vector
this->vec1.eraseObject(bullet);
//vec1.erase(vec1.find(sp0));
//pVec1->erase(1);
//pVec1->eraseObject(sp0,true);
//pVec1->popBack();
// remove all elements
vec1.clear();
// declare and Init Array
Vector<Touch *> _touches;
// Attention!!! : Vector can hold pointers that is Ref or subclass of Ref (e.g.:Node) only,
// so for example Vector< Node* > is valid,
// but not Vector< int > or Vector< Node >, otherwise it will fail to compile.
[Blog](http://dev.bunnyhero.org/2014/01/cocos2d-x-30-beta-the-new-vector-class/)
[Wiki](http://www.cocos2d-x.org/wiki/Vector%3CT%3E)
Vector<Sprite *> allSoldiers;
// initialize a vector with a capacity
Vector<Sprite *> vec1(5);
HelloWorld::HelloWorld() : _bullets(100)
{
}
// or
this->_bullets = cocos2d::Vector<cocos2d::Sprite *>{100};