2013-10-12 15:25:45 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2017-02-14 14:36:57 +08:00
|
|
|
Copyright (c) 2013-2017 Chukong Technologies
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2013-10-12 15:25:45 +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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CC_SET_H__
|
|
|
|
#define __CC_SET_H__
|
2015-03-24 20:23:51 +08:00
|
|
|
/// @cond DO_NOT_SHOW
|
2013-10-12 15:25:45 +08:00
|
|
|
|
|
|
|
#include <set>
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "base/CCRef.h"
|
|
|
|
#include "base/CCDataVisitor.h"
|
2013-10-12 15:25:45 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup data_structures
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
typedef std::set<Ref *>::iterator __SetIterator;
|
2013-10-12 15:25:45 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
class CC_DLL __Set : public Ref
|
2013-10-12 15:25:45 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2013-12-06 18:16:58 +08:00
|
|
|
__Set(void);
|
|
|
|
__Set(const __Set &rSetObject);
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-12-06 18:16:58 +08:00
|
|
|
virtual ~__Set(void);
|
2013-10-12 15:25:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Create and return a new empty set.
|
|
|
|
*/
|
2013-12-06 18:16:58 +08:00
|
|
|
static __Set * create();
|
2013-10-12 15:25:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*@brief Return a copy of the Set, it will copy all the elements.
|
|
|
|
*/
|
2013-12-06 18:16:58 +08:00
|
|
|
__Set* copy();
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
*@brief It is the same as copy().
|
|
|
|
*/
|
2013-12-06 18:16:58 +08:00
|
|
|
__Set* mutableCopy();
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
*@brief Return the number of elements the Set contains.
|
|
|
|
*/
|
|
|
|
int count();
|
|
|
|
/**
|
|
|
|
*@brief Add a element into Set, it will retain the element.
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
void addObject(Ref *pObject);
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
*@brief Remove the given element, nothing todo if no element equals pObject.
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
void removeObject(Ref *pObject);
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
*@brief Remove all elements of the set
|
|
|
|
*/
|
|
|
|
void removeAllObjects();
|
|
|
|
/**
|
|
|
|
*@brief Check if Set contains a element equals pObject.
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
bool containsObject(Ref *pObject);
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
*@brief Return the iterator that points to the first element.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-12-06 18:16:58 +08:00
|
|
|
__SetIterator begin();
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
*@brief Return the iterator that points to the position after the last element.
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-12-06 18:16:58 +08:00
|
|
|
__SetIterator end();
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
*@brief Return the first element if it contains elements, or null if it doesn't contain any element.
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
Ref* anyObject();
|
2013-10-12 15:25:45 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual void acceptVisitor(DataVisitor &visitor);
|
|
|
|
|
|
|
|
private:
|
2014-02-20 10:53:49 +08:00
|
|
|
std::set<Ref *> *_set;
|
2013-10-12 15:25:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// end of data_structure group
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
2015-03-24 20:23:51 +08:00
|
|
|
/// @endcond
|
2013-10-12 15:25:45 +08:00
|
|
|
#endif // __CC_SET_H__
|