1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/Tr1hash.h
12 #ifndef ZYPP_BASE_TR1HASH_H
13 #define ZYPP_BASE_TR1HASH_H
16 #include <tr1/unordered_set>
17 #include <tr1/unordered_map>
19 /** Define hash function for id based classes.
20 * Class has to provide a method \c id() retuning a unique number.
22 * // in global namespace define:
23 * ZYPP_DEFINE_ID_HASHABLE( ::zypp::sat::Sovable )
26 #define ZYPP_DEFINE_ID_HASHABLE(C) \
27 namespace std { namespace tr1 { \
28 template<class _Tp> struct hash; \
29 template<> struct hash<C> \
31 size_t operator()( const C & __s ) const \
32 { return __s.id(); } \
36 ///////////////////////////////////////////////////////////////////
38 { /////////////////////////////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////
41 { /////////////////////////////////////////////////////////////////
43 /** clone function for RW_pointer */
45 inline unordered_set<_D> * rwcowClone( const std::tr1::unordered_set<_D> * rhs )
46 { return new std::tr1::unordered_set<_D>( *rhs ); }
48 /** clone function for RW_pointer */
49 template<class _K, class _V>
50 inline std::tr1::unordered_map<_K,_V> * rwcowClone( const std::tr1::unordered_map<_K,_V> * rhs )
51 { return new std::tr1::unordered_map<_K,_V>( *rhs ); }
53 /////////////////////////////////////////////////////////////////
55 ///////////////////////////////////////////////////////////////////
56 /////////////////////////////////////////////////////////////////
58 ///////////////////////////////////////////////////////////////////
59 #endif // ZYPP_BASE_TR1HASH_H