1 /*------------------------------------------------------------------------
2 Junction: Concurrent data structures in C++
3 Copyright (c) 2016 Jeff Preshing
5 Distributed under the Simplified BSD License.
6 Original location: https://github.com/preshing/junction
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the LICENSE file for more information.
11 ------------------------------------------------------------------------*/
13 #ifndef JUNCTION_MAPTRAITS_H
14 #define JUNCTION_MAPTRAITS_H
16 #include <junction/Core.h>
17 #include <turf/Util.h>
22 struct DefaultKeyTraits {
24 typedef typename turf::util::BestFit<T>::Unsigned Hash;
25 static const Hash NullHash = Hash(0);
26 static Hash hash(T key) {
27 return turf::util::avalanche(Hash(key));
29 static Key dehash(Hash hash) {
30 return (T) turf::util::deavalanche(hash);
35 struct DefaultValueTraits {
37 typedef typename turf::util::BestFit<T>::Unsigned IntType;
38 static const IntType NullValue = 0;
39 static const IntType Redirect = 1;
42 } // namespace junction
44 #endif // JUNCTION_MAPTRAITS_H