cocos2dx 3.0 ----- __Array

1、声明

class CC_DLL __Array : public Object, public Clonable

2、__Array内部实现有两个版本,一个由std::vector管理数据,一个由ccArray管理数据。并用宏CC_USE_ARRAY_VECTOR来选择开启哪个版本。

若开启CC_USE_ARRAY_VECTOR版本,cocos会为我们提供一个自动管理指针的类RCPtr。此类可像shared_ptr那样,以对象的形式管理指针,防止内存泄露!

3、__Array的操作

①宏

CCARRAY_FOREACH(arr, obj)

CCARRAY_FOREACH_REVERSE(arr, obj)

CCARRAY_VERIFY_TYPE(arr, type) (用于debug版,release版无效)

arrayMakeObjectsPerformSelector(arr, func, type)

arrayMakeObjectsPerformSelectorWithObject(arr, func, obj, type)

②成员函数

create()

create(Object* object, ...)

 createWithObject(Object* object)

createWithCapacity(ssize_t capacity);

createWithArray(__Array* otherArray);

createWithContentsOfFile(const std::string& pFileName);

createWithContentsOfFileThreadSafe(const std::string& pFileName);

init();

initWithObject(Object* object); 

initWithObjects(Object* object, ...)

initWithCapacity(ssize_t capacity);

initWithArray(__Array* otherArray);

count()

capacity() 

getIndexOfObject(Object* object)

getObjectAtIndex(ssize_t index)

getLastObject()

containsObject(Object* object)

isEqualToArray(__Array* otherArray)

addObject(Object* object);

addObjectsFromArray(__Array* otherArray);

insertObject(Object* object, ssize_t index);

setObject(Object* object, ssize_t index);

fastSetObject(Object* object, ssize_t index)

swap( ssize_t indexOne, ssize_t indexTwo )

removeLastObject(bool releaseObj = true);

removeObject(Object* object, bool releaseObj = true);

removeObjectAtIndex(ssize_t index, bool releaseObj = true);

removeObjectsInArray(__Array* otherArray);

removeAllObjects();

fastRemoveObject(Object* object);

fastRemoveObjectAtIndex(ssize_t index);

exchangeObject(Object* object1, Object* object2);

exchangeObjectAtIndex(ssize_t index1, ssize_t index2);

replaceObjectAtIndex(ssize_t index, Object* object, bool releaseObject = true);

reverseObjects();

reduceMemoryFootprint();

acceptVisitor(DataVisitor &visitor);

clone() const;

Object** begin()

Object** end()

你可能感兴趣的:(cocos2dx,base,__Array)