diff --git a/cocos2dx/cocoa/NSSet.cpp b/cocos2dx/cocoa/NSSet.cpp index 4662cd6a0e..4c396a46a6 100644 --- a/cocos2dx/cocoa/NSSet.cpp +++ b/cocos2dx/cocoa/NSSet.cpp @@ -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(); +} diff --git a/cocos2dx/cocoa/NSSet.h b/cocos2dx/cocoa/NSSet.h index 5c6ecfd3e4..761694779d 100644 --- a/cocos2dx/cocoa/NSSet.h +++ b/cocos2dx/cocoa/NSSet.h @@ -25,5 +25,32 @@ THE SOFTWARE. #ifndef __NS_SET_H__ #define __NS_SET_H__ +#include +#include "NSObject.h" + +typedef std::set::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 m_set; +}; + +typedef NSSet NSMutableSet; + #endif // __NS_SET_H__