Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************************************************
- created: 2008/06/24
- created: 24:6:2008 0:27
- filename: c:\Program Files\Microsoft Visual Studio 9.0\VC\include\ozlib\hashtable.h
- file path: c:\Program Files\Microsoft Visual Studio 9.0\VC\include\ozlib
- file base: hashtable
- file ext: h
- author: Eric Smaxwill
- purpose: C# Hashtable implementation
- *********************************************************************/
- #pragma once
- #include <map>
- #include <ozlib/types.h>
- #include <ozlib/array.h>
- NAMESPACE_BEGIN
- //extraction macros from iterator P
- #define KEY( p ) (*p).first
- #define VALUE( p ) (*p).second
- template <typename _Key, typename _Value>
- class Hashtable
- {
- private:
- std::map<_Key, _Value> m_Table;
- ozlib::array<_Key> m_Keys;
- public:
- _Value& operator[]( _Key keyVal )
- {
- std::map<_Key, _Value>::iterator itr = m_Table.find( keyVal );
- if(itr!=m_Table.end())
- {
- if(!m_Keys.contains( keyVal )) m_Keys.Add(keyVal);
- return VALUE(itr);
- }
- else
- {
- if(!m_Keys.contains( keyVal )) m_Keys.Add(keyVal);
- return m_Table[keyVal];
- }
- }
- ozlib::array<_Key> Keys() const
- {
- return m_Keys;
- }
- };
- NAMESPACE_END
Add Comment
Please, Sign In to add comment