mirror of https://github.com/axmolengine/axmol.git
issue #6: implement NSSet
This commit is contained in:
parent
63b87af767
commit
92bf801870
|
@ -22,3 +22,60 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "NSSet.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
NSSet::NSSet(void)
|
||||
{
|
||||
}
|
||||
|
||||
NSSet::NSSet(const NSSet &rSetObject) : m_set(rSetObject.m_set)
|
||||
{
|
||||
}
|
||||
|
||||
NSSet::~NSSet(void)
|
||||
{
|
||||
}
|
||||
|
||||
NSSet* NSSet::copy(void)
|
||||
{
|
||||
NSSet *pSet = new NSSet(*this);
|
||||
|
||||
return pSet;
|
||||
}
|
||||
|
||||
NSSet* NSSet::mutableCopy(void)
|
||||
{
|
||||
return copy();
|
||||
}
|
||||
|
||||
int NSSet::count(void)
|
||||
{
|
||||
return (int)m_set.size();
|
||||
}
|
||||
|
||||
void NSSet::addObject(NSObject *pObject)
|
||||
{
|
||||
m_set.insert(pObject);
|
||||
}
|
||||
|
||||
void NSSet::removeObject(NSObject *pObject)
|
||||
{
|
||||
m_set.erase(pObject);
|
||||
}
|
||||
|
||||
bool NSSet::containsObject(NSObject *pObject)
|
||||
{
|
||||
return m_set.find(pObject) != m_set.end();
|
||||
}
|
||||
|
||||
NSSetIterator NSSet::begin(void)
|
||||
{
|
||||
return m_set.begin();
|
||||
}
|
||||
|
||||
NSSetIterator NSSet::end(void)
|
||||
{
|
||||
return m_set.end();
|
||||
}
|
||||
|
|
|
@ -25,5 +25,32 @@ THE SOFTWARE.
|
|||
#ifndef __NS_SET_H__
|
||||
#define __NS_SET_H__
|
||||
|
||||
#include <set>
|
||||
#include "NSObject.h"
|
||||
|
||||
typedef std::set<NSObject *>::iterator NSSetIterator;
|
||||
|
||||
class NSSet : public NSObject
|
||||
{
|
||||
public:
|
||||
NSSet(void);
|
||||
NSSet(const NSSet &rSetObject);
|
||||
virtual ~NSSet(void);
|
||||
|
||||
NSSet* copy();
|
||||
NSSet* mutableCopy();
|
||||
int count();
|
||||
void addObject(NSObject *pObject);
|
||||
void removeObject(NSObject *pObject);
|
||||
bool containsObject(NSObject *pObject);
|
||||
NSSetIterator begin();
|
||||
NSSetIterator end();
|
||||
|
||||
private:
|
||||
std::set<NSObject *> m_set;
|
||||
};
|
||||
|
||||
typedef NSSet NSMutableSet;
|
||||
|
||||
#endif // __NS_SET_H__
|
||||
|
||||
|
|
Loading…
Reference in New Issue