2010-07-06 20:23:58 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
2010-07-06 20:55:05 +08:00
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
2010-07-06 20:23:58 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __COCOA_NS_MUTATLE_ARRAY_H__
|
|
|
|
#define __COCOA_NS_MUTATLE_ARRAY_H__
|
|
|
|
|
|
|
|
#include "NSObject.h"
|
2010-07-12 18:20:04 +08:00
|
|
|
#include "../platform/platform.h"
|
2010-07-06 20:23:58 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2010-07-13 11:49:11 +08:00
|
|
|
typedef std::vector<NSObject *>::iterator NSMutableArrayIterator;
|
|
|
|
|
2010-07-16 14:19:21 +08:00
|
|
|
class NSMutableArray : public NSObject
|
2010-07-07 14:22:24 +08:00
|
|
|
{
|
|
|
|
public:
|
2010-07-12 17:01:26 +08:00
|
|
|
NSMutableArray(UINT32 uSize = 0);
|
|
|
|
~NSMutableArray(void);
|
2010-07-07 14:22:24 +08:00
|
|
|
|
|
|
|
UINT32 count(void);
|
|
|
|
UINT32 getIndexOfObject(NSObject *pObject);
|
2010-07-08 10:53:52 +08:00
|
|
|
bool containsObject(NSObject *pObject);
|
2010-07-12 17:01:26 +08:00
|
|
|
NSObject* getLastObject(void);
|
2010-07-14 11:02:06 +08:00
|
|
|
NSObject* getObjectAtIndex(UINT32 uIndex);
|
2010-07-07 14:22:24 +08:00
|
|
|
|
|
|
|
// Adding objects
|
|
|
|
void addObject(NSObject *pObject);
|
2010-07-12 17:01:26 +08:00
|
|
|
void addObjectsFromArray(NSMutableArray *pArray);
|
2010-07-07 14:22:24 +08:00
|
|
|
void insertObjectAtIndex(NSObject *pObject, UINT32 uIndex);
|
|
|
|
|
|
|
|
// Removing objects
|
|
|
|
void removeLastObject(void);
|
|
|
|
void removeObject(NSObject *pObject);
|
2010-07-12 17:01:26 +08:00
|
|
|
void removeObjectAtIndex(UINT32 uIndex);
|
2010-07-07 14:22:24 +08:00
|
|
|
void removeAllObjects(void);
|
2010-07-12 17:01:26 +08:00
|
|
|
|
2010-07-16 14:19:21 +08:00
|
|
|
void replaceObjectAtIndex(UINT32 uIndex, NSObject *pObject);
|
|
|
|
|
2010-07-13 11:49:11 +08:00
|
|
|
NSMutableArrayIterator begin(void);
|
|
|
|
NSMutableArrayIterator end(void);
|
2010-07-12 17:01:26 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
static NSMutableArray* arrayWithObjects(NSObject *pObject1, ...);
|
|
|
|
static NSMutableArray* arrayWithArray(NSMutableArray *pArray);
|
|
|
|
|
2010-07-07 14:22:24 +08:00
|
|
|
private:
|
|
|
|
std::vector<NSObject *> m_array;
|
|
|
|
};
|
|
|
|
|
2010-07-06 20:23:58 +08:00
|
|
|
#endif // __COCOA_NS_MUTATLE_ARRAY_H__
|