CCMutableDictionary question

Hi
From source code of CCMutableDictionary, we get this:

template
class CCMutableDictionary : public CCObject
{
public:
    typedef std::map<_T, _ValueT>   CCObjectMap;
    typedef typename CCObjectMap::iterator  CCObjectMapIter;

protected:
    typedef pair<_T, _ValueT> Int_Pair;
    CCObjectMap     m_Map;
    bool            m_bBegin;
    CCObjectMapIter m_MapIter;

public:
    CCMutableDictionary(void)
    {
        m_bBegin = false;
    }

    ~CCMutableDictionary(void)
    {
        removeAllObjects();
    }

    /// return the number of items
    unsigned int count()
    {
        return m_Map.size();
    }

    /// return all the keys
    std::vector allKeys()
    {
        std::vector tRet;
        if (m_Map.size() > 0)
        {
            CCObjectMapIter it;
            for( it = m_Map.begin(); it != m_Map.end(); ++it)
            {
                tRet.push_back(it->first);
            }
        }
        return tRet;
    }

    /** @warning : We use '==' to compare two objects*/
    std::vector allKeysForObject(_ValueT object)
    {
        std::vector tRet;
        if (m_Map.size() > 0)
        {
            CCObjectMapIter it;
            for( it= m_Map.begin(); it != m_Map.end(); ++it)
            {
                if (it->second == object)
                {
                    tRet.push_back(it->first);
                }
            }
        }
        return tRet;
    }
........
........

the function allKeys() and allKeysForObject() return a vector of map<*T,*TValue> keys.
I think it should be std::vector<_T> not std::vectorstd::string

I think you’re right. We always use CCMutalbeDictionary<std::string, CCObject*> so this bug hasn’t appeared.
Thanks for your feedback!
Or maybe we would modify this class to

template
class CCMutableDictionary : public CCObject
{
public:
    typedef std::map    CCObjectMap;

since the key is always a string

Issue #576 is created for this case.

Hi Walzer
Thank you for quick reply.

I think using template<class _T, class _ValueT = CCObject*> is better, we are now using cocos2d-x to port our game from ios to android and we found CCMutableDictionary is very useful to replace objective-c’s NSMutableDictionary. If using fixed std::string, we can’t use CCMutableDictionary to other place.

Have a nice day!

OK, so I’ll keep this design.
bug #576 fixed just now.