2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2012-06-11 21:58:04 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-06-11 21:58:04 +08:00
|
|
|
#ifndef __CC_SET_H__
|
|
|
|
#define __CC_SET_H__
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include "CCObject.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup data_structures
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
typedef std::set<Object *>::iterator SetIterator;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Set : public Object
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:13:12 +08:00
|
|
|
Set(void);
|
|
|
|
Set(const Set &rSetObject);
|
|
|
|
virtual ~Set(void);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-03-14 01:58:24 +08:00
|
|
|
/**
|
|
|
|
* @brief Create and return a new empty set.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
static Set * create();
|
2013-03-14 01:58:24 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
*@brief Return a copy of the Set, it will copy all the elements.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
Set* copy();
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
|
|
|
*@brief It is the same as copy().
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
Set* mutableCopy();
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
*@brief Return the number of elements the Set contains.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
|
|
|
int count();
|
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
*@brief Add a element into Set, it will retain the element.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void addObject(Object *pObject);
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
|
|
|
*@brief Remove the given element, nothing todo if no element equals pObject.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
void removeObject(Object *pObject);
|
2012-11-30 09:00:34 +08:00
|
|
|
/**
|
|
|
|
*@brief Remove all elements of the set
|
|
|
|
*/
|
|
|
|
void removeAllObjects();
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
*@brief Check if Set contains a element equals pObject.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
bool containsObject(Object *pObject);
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
|
|
|
*@brief Return the iterator that points to the first element.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
SetIterator begin();
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2012-09-17 15:02:24 +08:00
|
|
|
*@brief Return the iterator that points to the position after the last element.
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
SetIterator end();
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
|
|
|
*@brief Return the first element if it contains elements, or null if it doesn't contain any element.
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
Object* anyObject();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void acceptVisitor(DataVisitor &visitor);
|
2013-05-10 15:07:05 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
private:
|
2013-06-20 14:13:12 +08:00
|
|
|
std::set<Object *> *_set;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of data_structure group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
2012-06-11 21:58:04 +08:00
|
|
|
#endif // __CC_SET_H__
|
2012-04-19 14:35:52 +08:00
|
|
|
|