1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/Hash.h
12 #ifndef ZYPP_BASE_HASH_H
13 #define ZYPP_BASE_HASH_H
16 #include <unordered_set>
17 #include <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::Solvable )
26 #define ZYPP_DEFINE_ID_HASHABLE(C) \
28 template<class Tp> struct hash; \
29 template<> struct hash<C> \
31 size_t operator()( const C & __s ) const \
32 { return __s.id(); } \
36 ///////////////////////////////////////////////////////////////////
39 /** clone function for RW_pointer */
41 inline unordered_set<D> * rwcowClone( const std::unordered_set<D> * rhs )
42 { return new std::unordered_set<D>( *rhs ); }
44 /** clone function for RW_pointer */
45 template<class K, class V>
46 inline std::unordered_map<K,V> * rwcowClone( const std::unordered_map<K,V> * rhs )
47 { return new std::unordered_map<K,V>( *rhs ); }
49 ///////////////////////////////////////////////////////////////////
50 #endif // ZYPP_BASE_HASH_H