cocos2d-x  3.0-alpha0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Array Class Reference

#include <CCArray.h>

Inheritance diagram for Array:
Object Clonable ArrayForObjectSorting

Public Member Functions

 ~Array ()
bool init ()
 Initializes an array. More...
 
bool initWithObject (Object *object)
 Initializes an array with one object. More...
 
bool initWithObjects (Object *object,...) CC_REQUIRES_NULL_TERMINATION
 Initializes an array with some objects. More...
 
bool initWithCapacity (int capacity)
 Initializes an array with capacity. More...
 
bool initWithArray (Array *otherArray)
 Initializes an array with an existing array. More...
 
int count () const
 Returns element count of the array. More...
 
int capacity () const
 Returns capacity of the array. More...
 
int getIndexOfObject (Object *object) const
 Returns index of a certain object, return UINT_MAX if doesn't contain the object. More...
 
CC_DEPRECATED_ATTRIBUTE int indexOfObject (Object *object) const
local indexOfObject ( local object)
ObjectgetObjectAtIndex (int index)
 Returns an element with a certain index. More...
 
CC_DEPRECATED_ATTRIBUTE ObjectobjectAtIndex (int index)
ObjectgetLastObject ()
 Returns the last element of the array. More...
 
CC_DEPRECATED_ATTRIBUTE ObjectlastObject ()
ObjectgetRandomObject ()
 Returns a random element. More...
 
CC_DEPRECATED_ATTRIBUTE ObjectrandomObject ()
local randomObject ()
bool containsObject (Object *object) const
 Returns a Boolean value that indicates whether object is present in array. More...
 
bool isEqualToArray (Array *otherArray)
void addObject (Object *object)
 Add a certain object. More...
 
void addObjectsFromArray (Array *otherArray)
local addObjectsFromArray ( local otherArray)
void insertObject (Object *object, int index)
 Insert a certain object at a certain index. More...
 
void setObject (Object *object, int index)
 sets a certain object at a certain index More...
 
void fastSetObject (Object *object, int index)
 sets a certain object at a certain index without retaining. More...
 
void swap (int indexOne, int indexTwo)
void removeLastObject (bool releaseObj=true)
 Remove last object. More...
 
void removeObject (Object *object, bool releaseObj=true)
 Remove a certain object. More...
 
void removeObjectAtIndex (int index, bool releaseObj=true)
 Remove an element with a certain index. More...
 
void removeObjectsInArray (Array *otherArray)
 Remove all elements. More...
 
void removeAllObjects ()
 Remove all objects. More...
 
void fastRemoveObject (Object *object)
 Fast way to remove a certain object. More...
 
void fastRemoveObjectAtIndex (int index)
 Fast way to remove an element with a certain index. More...
 
void exchangeObject (Object *object1, Object *object2)
 Swap two elements. More...
 
void exchangeObjectAtIndex (int index1, int index2)
 Swap two elements with certain indexes. More...
 
local exchangeObjectAtIndex ( local index1, local index2)
 Swap two elements with certain indexes. More...
 
void replaceObjectAtIndex (int index, Object *object, bool releaseObject=true)
 Replace object at index with another object. More...
 
void reverseObjects ()
 Revers the array. More...
 
void reduceMemoryFootprint ()
virtual void acceptVisitor (DataVisitor &visitor)
virtual Arrayclone () const
 returns a copy of the object More...
 
Object ** begin ()
Object ** end ()
 Array ()
- Public Member Functions inherited from Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
void release ()
 Release the ownership immediately. More...
 
void retain ()
 Retains the ownership. More...
 
Objectautorelease ()
 Release the ownership sometime soon automatically. More...
 
bool isSingleReference () const
 Returns a boolean value that indicates whether there is only one reference to the object. More...
 
unsigned int retainCount () const
 Returns the object's current reference count. More...
 
virtual bool isEqual (const Object *object)
 Returns a boolean value that indicates whether this object and a given object are equal. More...
 
virtual void update (float dt)
- Public Member Functions inherited from Clonable
virtual ~Clonable ()
CC_DEPRECATED_ATTRIBUTE Objectcopy () const
 returns a copy of the object. More...
 
local copy ()
 returns a copy of the object. More...
 

Static Public Member Functions

static Arraycreate ()
 Creates an empty array. More...
 
static Arraycreate (Object *object,...) CC_REQUIRES_NULL_TERMINATION
 Create an array with objects. More...
 
local create ( local object)
 Create an array with objects. More...
 
static ArraycreateWithObject (Object *object)
 Create an array with one object. More...
 
local createWithObject ( local object)
 Create an array with one object. More...
 
static ArraycreateWithCapacity (int capacity)
 Create an array with a default capacity. More...
 
static ArraycreateWithArray (Array *otherArray)
 Create an array with from an existing array. More...
 
static ArraycreateWithContentsOfFile (const char *pFileName)
 Generate a Array pointer by file. More...
 
local createWithContentsOfFile ( local pFileName)
 Generate a Array pointer by file. More...
 
static ArraycreateWithContentsOfFileThreadSafe (const char *pFileName)

Public Attributes

ccArray * data
- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 

Additional Inherited Members

- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
var _reference
 count of references More...
 
local _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 
var _autoReleaseCount
 count of autorelease More...
 
local _autoReleaseCount
 count of autorelease More...
 

Constructor & Destructor Documentation

~Array ( )
Array ( )

Member Function Documentation

virtual void acceptVisitor ( DataVisitor visitor)
virtual

Reimplemented from Object.

var acceptVisitor ( var  visitor)
virtual

Reimplemented from Object.

local acceptVisitor ( local  visitor)
virtual

Reimplemented from Object.

void addObject ( Object object)

Add a certain object.

local addObject ( local  object)

Add a certain object.

void addObjectsFromArray ( Array otherArray)
local addObjectsFromArray ( local  otherArray)
Object** begin ( )
inline
int capacity ( ) const
inline

Returns capacity of the array.

local capacity ( )
inline

Returns capacity of the array.

virtual Array* clone ( ) const
virtual

returns a copy of the object

Implements Clonable.

bool containsObject ( Object object) const

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

local containsObject ( local  object)

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

int count ( ) const
inline

Returns element count of the array.

local count ( )
inline

Returns element count of the array.

static Array* create ( )
static

Creates an empty array.

Default capacity is 10

static Array* create ( Object object,
  ... 
)
static

Create an array with objects.

local create ( local  object,
  ... 
)
static

Create an array with objects.

static Array* createWithArray ( Array otherArray)
static

Create an array with from an existing array.

local createWithArray ( local  otherArray)
static

Create an array with from an existing array.

static Array* createWithCapacity ( int  capacity)
static

Create an array with a default capacity.

local createWithCapacity ( local  capacity)
static

Create an array with a default capacity.

static Array*
createWithContentsOfFile
( const char *  pFileName)
static

Generate a Array pointer by file.

Parameters
pFileNameThe file name of *.plist file
Returns
The Array pointer generated from the file
local createWithContentsOfFile ( local  pFileName)
static

Generate a Array pointer by file.

Parameters
pFileNameThe file name of *.plist file
Returns
The Array pointer generated from the file
static Array*
createWithContentsOfFileThreadSafe
( const char *  pFileName)
static
var
createWithContentsOfFileThreadSafe
( var  pFileName)
static
local
createWithContentsOfFileThreadSafe
( local  pFileName)
static
static Array* createWithObject ( Object object)
static

Create an array with one object.

local createWithObject ( local  object)
static

Create an array with one object.

Object** end ( )
inline
void exchangeObject ( Object object1,
Object object2 
)

Swap two elements.

local exchangeObject ( local  object1,
local  object2 
)

Swap two elements.

void exchangeObjectAtIndex ( int  index1,
int  index2 
)

Swap two elements with certain indexes.

local exchangeObjectAtIndex ( local  index1,
local  index2 
)

Swap two elements with certain indexes.

void fastRemoveObject ( Object object)

Fast way to remove a certain object.

local fastRemoveObject ( local  object)

Fast way to remove a certain object.

void fastRemoveObjectAtIndex ( int  index)

Fast way to remove an element with a certain index.

local fastRemoveObjectAtIndex ( local  index)

Fast way to remove an element with a certain index.

void fastSetObject ( Object object,
int  index 
)
inline

sets a certain object at a certain index without retaining.

Use it with caution

int getIndexOfObject ( Object object) const

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

Object* getLastObject ( )
inline

Returns the last element of the array.

local getLastObject ( )
inline

Returns the last element of the array.

Object* getObjectAtIndex ( int  index)
inline

Returns an element with a certain index.

Object* getRandomObject ( )

Returns a random element.

CC_DEPRECATED_ATTRIBUTE int
indexOfObject
( Object object) const
inline
local indexOfObject ( local  object)
inline
bool init ( )

Initializes an array.

bool initWithArray ( Array otherArray)

Initializes an array with an existing array.

bool initWithCapacity ( int  capacity)

Initializes an array with capacity.

bool initWithObject ( Object object)

Initializes an array with one object.

bool initWithObjects ( Object object,
  ... 
)

Initializes an array with some objects.

void insertObject ( Object object,
int  index 
)

Insert a certain object at a certain index.

local insertObject ( local  object,
local  index 
)

Insert a certain object at a certain index.

bool isEqualToArray ( Array otherArray)
Since
1.1
local isEqualToArray ( local  otherArray)
Since
1.1
CC_DEPRECATED_ATTRIBUTE Object*
lastObject
( )
inline
local lastObject ( )
inline
CC_DEPRECATED_ATTRIBUTE Object*
objectAtIndex
( int  index)
inline
var objectAtIndex ( var  index)
inline
local objectAtIndex ( local  index)
inline
CC_DEPRECATED_ATTRIBUTE Object*
randomObject
( )
inline
local randomObject ( )
inline
void reduceMemoryFootprint ( )
var reduceMemoryFootprint ( )
local reduceMemoryFootprint ( )
void removeAllObjects ( )

Remove all objects.

local removeAllObjects ( )

Remove all objects.

void removeLastObject ( bool  releaseObj = true)

Remove last object.

local removeLastObject ( local  releaseObj = true)

Remove last object.

void removeObject ( Object object,
bool  releaseObj = true 
)

Remove a certain object.

local removeObject ( local  object,
local  releaseObj = true 
)

Remove a certain object.

void removeObjectAtIndex ( int  index,
bool  releaseObj = true 
)

Remove an element with a certain index.

local removeObjectAtIndex ( local  index,
local  releaseObj = true 
)

Remove an element with a certain index.

void removeObjectsInArray ( Array otherArray)

Remove all elements.

local removeObjectsInArray ( local  otherArray)

Remove all elements.

void replaceObjectAtIndex ( int  index,
Object object,
bool  releaseObject = true 
)

Replace object at index with another object.

local replaceObjectAtIndex ( local  index,
local  object,
local  releaseObject = true 
)

Replace object at index with another object.

void reverseObjects ( )

Revers the array.

local reverseObjects ( )

Revers the array.

void setObject ( Object object,
int  index 
)

sets a certain object at a certain index

void swap ( int  indexOne,
int  indexTwo 
)
inline

Member Data Documentation

ccArray* data
var data
local data

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