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

#include <CCSorting.h>

Inheritance diagram for ArrayForObjectSorting:
Array Object Clonable

Public Member Functions

 ArrayForObjectSorting ()
void insertSortedObject (SortableObject *object)
 Inserts a given object into array. More...
 
void removeSortedObject (SortableObject *object)
 Removes an object in array. More...
 
void setObjectID_ofSortedObject (unsigned int tag, SortableObject *object)
 Sets a new value of the key for the given object. More...
 
SortableObjectobjectWithObjectID (long tag)
SortableObjectgetObjectWithObjectID (unsigned int tag)
 Returns an object with given key and value. More...
 
long indexOfSortedObject (SortableObject *obj)
 Returns an index of the object with given key and value. More...
 
- Public Member Functions inherited from Array
 ~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 (long capacity)
 Initializes an array with capacity. More...
 
bool initWithArray (Array *otherArray)
 Initializes an array with an existing array. More...
 
long count () const
 Returns element count of the array. More...
 
local count ()
 Returns element count of the array. More...
 
long capacity () const
 Returns capacity of the array. More...
 
local capacity ()
 Returns capacity of the array. More...
 
long getIndexOfObject (Object *object) const
 Returns index of a certain object, return UINT_MAX if doesn't contain the object. More...
 
CC_DEPRECATED_ATTRIBUTE long indexOfObject (Object *object) const
local indexOfObject ( local object)
ObjectgetObjectAtIndex (long index)
 Returns an element with a certain index. More...
 
CC_DEPRECATED_ATTRIBUTE ObjectobjectAtIndex (long index)
local objectAtIndex ( local index)
ObjectgetLastObject ()
 Returns the last element of the array. More...
 
local getLastObject ()
 Returns the last element of the array. More...
 
CC_DEPRECATED_ATTRIBUTE ObjectlastObject ()
local lastObject ()
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, long index)
 Insert a certain object at a certain index. More...
 
local insertObject ( local object, local index)
 Insert a certain object at a certain index. More...
 
void setObject (Object *object, long index)
 sets a certain object at a certain index More...
 
void fastSetObject (Object *object, long index)
 sets a certain object at a certain index without retaining. More...
 
void swap (long indexOne, long indexTwo)
void removeLastObject (bool releaseObj=true)
 Remove last object. More...
 
local removeLastObject ( local true)
 Remove last object. More...
 
void removeObject (Object *object, bool releaseObj=true)
 Remove a certain object. More...
 
local removeObject ( local object, local true)
 Remove a certain object. More...
 
void removeObjectAtIndex (long index, bool releaseObj=true)
 Remove an element with a certain index. More...
 
local removeObjectAtIndex ( local index, local true)
 Remove an element with a certain index. More...
 
void removeObjectsInArray (Array *otherArray)
 Remove all elements. More...
 
void removeAllObjects ()
 Remove all objects. More...
 
local removeAllObjects ()
 Remove all objects. More...
 
void fastRemoveObject (Object *object)
 Fast way to remove a certain object. More...
 
local fastRemoveObject ( local object)
 Fast way to remove a certain object. More...
 
void fastRemoveObjectAtIndex (long index)
 Fast way to remove an element with a certain index. More...
 
local fastRemoveObjectAtIndex ( local index)
 Fast way to remove an element with a certain index. More...
 
void exchangeObject (Object *object1, Object *object2)
 Swap two elements. More...
 
local exchangeObject ( local object1, local object2)
 Swap two elements. More...
 
void exchangeObjectAtIndex (long index1, long index2)
 Swap two elements with certain indexes. More...
 
local exchangeObjectAtIndex ( local index1, local index2)
 Swap two elements with certain indexes. More...
 
void replaceObjectAtIndex (long index, Object *object, bool releaseObject=true)
 Replace object at index with another object. More...
 
local replaceObjectAtIndex ( local index, local object, local true)
 Replace object at index with another object. More...
 
void reverseObjects ()
 Revers the array. More...
 
local reverseObjects ()
 Revers the array. More...
 
void reduceMemoryFootprint ()
var reduceMemoryFootprint ()
local reduceMemoryFootprint ()
virtual void acceptVisitor (DataVisitor &visitor)
local acceptVisitor ( local 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 ()
Objectcopy () const
 returns a copy of the object. More...
 
var copy ()
 returns a copy of the object. More...
 
local copy ()
 returns a copy of the object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Array
static Arraycreate ()
 Creates an empty array. More...
 
static Arraycreate (Object *object,...) CC_REQUIRES_NULL_TERMINATION
 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 (long capacity)
 Create an array with a default capacity. More...
 
local createWithCapacity ( local capacity)
 Create an array with a default capacity. More...
 
static ArraycreateWithArray (Array *otherArray)
 Create an array with from an existing array. More...
 
local createWithArray ( local 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 inherited from Array
ccArray * data
- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 

Constructor & Destructor Documentation

Member Function Documentation

SortableObject*
getObjectWithObjectID
( unsigned int  tag)

Returns an object with given key and value.

Returns an object with given key and value. If no object is found, it returns nil.

Parameters
tagThe value to locate object
Returns
object found or nil.
long indexOfSortedObject ( SortableObject obj)

Returns an index of the object with given key and value.

Returns the index of an object with given key and value. If no object is found, it returns an index at which the given object value would have been located. If object must be located at the end of array, it returns the length of the array, which is out of bound.

Parameters
objThe object
Returns
index of the object
void insertSortedObject ( SortableObject object)

Inserts a given object into array.

Inserts a given object into array with key and value that are used in sorting. "value" must respond to message, compare:, which returns (NSComparisonResult). If it does not respond to the message, it is appended. If the compare message does not result NSComparisonResult, sorting behavior is not defined. It ignores duplicate entries and inserts next to it.

Parameters
objectThe object to be inserted.
SortableObject* objectWithObjectID ( long  tag)
void removeSortedObject ( SortableObject object)

Removes an object in array.

Removes an object with given key and value. If no object is found in array with the key and value, no action is taken.

Parameters
objectThe object to be removed.
void setObjectID_ofSortedObject ( unsigned int  tag,
SortableObject object 
)

Sets a new value of the key for the given object.

In case where sorting value must be changed, this message must be sent to keep consistency of being sorted. If it is changed externally, it must be sorted completely again.

Parameters
tagThe value to be set to.
objectThe object which has the value.

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