Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename _TKey, typename _TValue>
- class map_ref
- {
- public:
- typedef _TKey TKey;
- typedef _TValue TValue;
- typedef std::map<_TKey, _TValue> TContainer;
- typedef typename TContainer::iterator iterator;
- typedef typename TContainer::const_iterator const_iterator;
- public:
- TContainer& Get() { return m_Container; }
- operator TContainer&() { return m_Container; }
- TContainer* operator->() { return &m_Container; }
- TContainer const* operator->() const { return &m_Container; }
- TValue& operator[](_TKey const& _key) { return m_Container[_key]; }
- TValue const& operator[](_TKey const& _key) const { return m_Container[_key]; }
- bool ContainsKey(_TKey const& _key) const
- {
- TContainer::const_iterator iteContainer = m_Container.find(_key);
- return iteContainer != m_Container.end();
- }
- bool Find(_TKey const& _key, TValue& _rValue) const
- {
- TContainer::const_iterator iteContainer = m_Container.find(_key);
- if ( iteContainer == m_Container.end() )
- return false;
- _rValue = iteContainer->second;
- return true;
- }
- template<typename T_FUNCTOR>
- void ForEach(T_FUNCTOR _functor) const
- {
- TContainer::const_iterator iteContainer = m_Container.begin();
- for ( ; iteContainer != m_Container.end() ; iteContainer++ )
- {
- _functor(iteContainer->first, iteContainer->second);
- }
- }
- private:
- TContainer m_Container;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement