diff --git a/cocos/base/CCMap.h b/cocos/base/CCMap.h index 4b940f2a78..9f7b6b17f6 100644 --- a/cocos/base/CCMap.h +++ b/cocos/base/CCMap.h @@ -25,10 +25,17 @@ #ifndef __CCMAP_H__ #define __CCMAP_H__ +#define USE_STD_UNORDERED_MAP 1 + #include "ccMacros.h" #include "CCObject.h" #include + +#if USE_STD_UNORDERED_MAP #include +#else +#include +#endif NS_CC_BEGIN @@ -44,7 +51,11 @@ public: // ------------------------------------------ // Iterators // ------------------------------------------ +#if USE_STD_UNORDERED_MAP typedef std::unordered_map RefMap; +#else + typedef std::map RefMap; +#endif typedef typename RefMap::iterator iterator; typedef typename RefMap::const_iterator const_iterator; @@ -104,25 +115,39 @@ public: /** Sets capacity of the map */ void reserve(ssize_t capacity) { +#if USE_STD_UNORDERED_MAP _data.reserve(capacity); +#endif } /** Returns the number of buckets in the Map container. */ ssize_t bucketCount() const { +#if USE_STD_UNORDERED_MAP return _data.bucket_count(); +#else + return 0; +#endif } /** Returns the number of elements in bucket n. */ ssize_t bucketSize(ssize_t n) const { +#if USE_STD_UNORDERED_MAP return _data.bucket_size(n); +#else + return 0; +#endif } /** Returns the bucket number where the element with key k is located. */ ssize_t bucket(const K& k) const { +#if USE_STD_UNORDERED_MAP return _data.bucket(k); +#else + return 0; +#endif } /** The number of elements in the map. */