libmoost
/home/mhx/git/github/libmoost/include/moost/container/policies/dense_hash_map.hpp
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #ifndef MOOST_DENSE_HASH_MAP_POLICY_HPP
00029 #define MOOST_DENSE_HASH_MAP_POLICY_HPP
00030 
00031 #include "generic_map.hpp"
00032 #include "../dense_hash_map.hpp"
00033 
00034 namespace moost { namespace container { namespace policies {
00035 
00039 template <typename TKey, typename TVal>
00040 class dense_hs_map : public generic_map< moost::container::dense_hash_map<TKey, TVal> >
00041 {
00042 public:
00043 
00044    typedef typename moost::container::dense_hash_map<TKey, TVal> map_type;
00045 
00046    dense_hs_map(TKey empty_key = TKey(), size_t hint_size = 0)
00047       : m_emptyKey(empty_key), m_hintSize(hint_size)
00048    {}
00049 
00050    virtual ~dense_hs_map(){}
00051 
00053    virtual void init(moost::container::dense_hash_map<TKey, TVal>& map) const
00054    {
00055       map.set_empty_key(m_emptyKey);
00056       if ( m_hintSize > 0 )
00057          map.resize(m_hintSize);
00058    }
00059 
00061    virtual void resize(moost::container::dense_hash_map<TKey, TVal>& map, size_t numKeys) const
00062    { map.resize(numKeys); }
00063 
00064 private:
00065    TKey   m_emptyKey;
00066    size_t m_hintSize;
00067 };
00068 
00069 // -----------------------------------------------------------------------------
00070 
00071 template <typename TKey, typename TVal>
00072 struct map_policy_selector< TKey, TVal, moost::container::dense_hash_map<TKey, TVal> >
00073 {
00074    // will return generic_map
00075    typedef dense_hs_map<TKey, TVal> policy_type;
00076 };
00077 
00078 }}}
00079 
00080 #endif // MOOST_DENSE_HASH_MAP_POLICY_HPP