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