]> www.ginac.de Git - cln.git/blob - src/base/hash/cl_rcpointer2_hashweak_rcpointer.h
Fix compilation error on MSVC.
[cln.git] / src / base / hash / cl_rcpointer2_hashweak_rcpointer.h
1 // cl_rcpointer hash tables
2
3 #ifndef _CL_RCPOINTER2_HASHWEAK_RCPOINTER_H
4 #define _CL_RCPOINTER2_HASHWEAK_RCPOINTER_H
5
6 #include "cln/object.h"
7
8 #include "base/hash/cl_hash2weak.h"
9
10 namespace cln {
11
12 // Equality.
13 static inline bool equal (const cl_rcpointer& x, const cl_rcpointer& y)
14 { return (x.pointer == y.pointer); }
15
16 // Hash code. Luckily objects don't move around in memory.
17 inline uintptr_t hashcode (const cl_rcpointer& x1, const cl_rcpointer& x2)
18 {
19         var uintptr_t hashcode1 = (uintptr_t)x1.pointer;
20         var uintptr_t hashcode2 = (uintptr_t)x2.pointer;
21         hashcode2 = (hashcode2 << 5) | (hashcode2 >> (long_bitsize-5)); // rotate
22         return hashcode1 ^ hashcode2;
23 }
24
25 typedef cl_htentry2<cl_rcpointer,cl_rcpointer,cl_rcpointer> cl_htentry_from_rcpointer2_to_rcpointer;
26
27 typedef cl_heap_weak_hashtable_2<cl_rcpointer,cl_rcpointer,cl_rcpointer> cl_heap_weak_hashtable_from_rcpointer2_to_rcpointer;
28
29 typedef _cl_hashtable_iterator<cl_htentry_from_rcpointer2_to_rcpointer> cl_hashtable_from_rcpointer2_to_rcpointer_iterator;
30
31 struct cl_wht_from_rcpointer2_to_rcpointer : public cl_rcpointer {
32         // Constructors.
33         cl_wht_from_rcpointer2_to_rcpointer (bool (*maygc_htentry) (const cl_htentry_from_rcpointer2_to_rcpointer&));
34         cl_wht_from_rcpointer2_to_rcpointer (const cl_wht_from_rcpointer2_to_rcpointer&);
35         // Assignment operators.
36         cl_wht_from_rcpointer2_to_rcpointer& operator= (const cl_wht_from_rcpointer2_to_rcpointer&);
37         // Iterator.
38         cl_hashtable_from_rcpointer2_to_rcpointer_iterator iterator () const
39         { return ((cl_heap_weak_hashtable_from_rcpointer2_to_rcpointer*)pointer)->iterator(); }
40         // Lookup.
41         cl_rcpointer * get (const cl_rcpointer& x, const cl_rcpointer& y) const;
42         // Store.
43         void put (const cl_rcpointer& x, const cl_rcpointer& y, const cl_rcpointer& z) const;
44 };
45
46 }  // namespace cln
47
48 #endif /* _CL_RCPOINTER2_HASHWEAK_RCPOINTER_H */