/****************************************************************************** @File PVRTMap.h @Title PVRTArray @Version @Copyright Copyright (c) Imagination Technologies Limited. All Rights Reserved. Strictly Confidential. @Platform ANSI compatible @Description A simple and easy to use implementation of a map. ******************************************************************************/ #ifndef __PVRTMAP_H__ #define __PVRTMAP_H__ #include "PVRTArray.h" /*!**************************************************************************** Class ******************************************************************************/ /*!*************************************************************************** * @Class CPVRTMap * @Brief Expanding map template class. * @Description A simple and easy to use implementation of a map. *****************************************************************************/ template class CPVRTMap { public: /*!*********************************************************************** @Function CPVRTMap @Return A new CPVRTMap. @Description Constructor for a CPVRTMap. *************************************************************************/ CPVRTMap() : m_Keys(), m_Data(), m_uiSize(0) {} /*!*********************************************************************** @Function ~CPVRTMap @Description Destructor for a CPVRTMap. *************************************************************************/ ~CPVRTMap() { //Clear the map, that's enough - the CPVRTArray members will tidy everything else up. Clear(); } EPVRTError Reserve(const PVRTuint32 uiSize) { //Sets the capacity of each member array to the requested size. The array used will only expand. //Returns the most serious error from either method. return PVRT_MAX(m_Keys.SetCapacity(uiSize),m_Data.SetCapacity(uiSize)); } /*!*********************************************************************** @Function GetSize @Return Number of meaningful members in the map. @Description Returns the number of meaningful members in the map. *************************************************************************/ PVRTuint32 GetSize() const { //Return the size. return m_uiSize; } /*!*********************************************************************** @Function GetIndexOf @Input key @Return The index value for a mapped item. @Description Gets the position of a particular key/data within the map. If the return value is exactly equal to the value of GetSize() then the item has not been found. *************************************************************************/ PVRTuint32 GetIndexOf(const KeyType key) const { //Loop through all the valid keys. for (PVRTuint32 i=0; i m_Keys; //Array of pointers to all the allocated data. CPVRTArray m_Data; //The number of meaningful members in the map. PVRTuint32 m_uiSize; }; #endif // __PVRTMAP_H__ /***************************************************************************** End of file (PVRTMap.h) *****************************************************************************/