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 Key NullKey = Key(0);
26 static const Hash NullHash = Hash(0);
27 static Hash hash(T key) {
28 return turf::util::avalanche(Hash(key));
30 static Key dehash(Hash hash) {
31 return (T) turf::util::deavalanche(hash);
36 struct DefaultValueTraits {
38 typedef typename turf::util::BestFit<T>::Unsigned IntType;
39 static const IntType NullValue = 0;
40 static const IntType Redirect = 1;
43 } // namespace junction
45 #endif // JUNCTION_MAPTRAITS_H