1 // cl_rcpointer hash tables
3 #ifndef _CL_RCPOINTER2_HASHWEAK_RCPOINTER_H
4 #define _CL_RCPOINTER2_HASHWEAK_RCPOINTER_H
6 #include "cln/object.h"
8 #include "base/hash/cl_hash2weak.h"
13 static inline bool equal (const cl_rcpointer& x, const cl_rcpointer& y)
14 { return (x.pointer == y.pointer); }
16 // Hash code. Luckily objects don't move around in memory.
17 inline uintptr_t hashcode (const cl_rcpointer& x1, const cl_rcpointer& x2)
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;
25 typedef cl_htentry2<cl_rcpointer,cl_rcpointer,cl_rcpointer> cl_htentry_from_rcpointer2_to_rcpointer;
27 typedef cl_heap_weak_hashtable_2<cl_rcpointer,cl_rcpointer,cl_rcpointer> cl_heap_weak_hashtable_from_rcpointer2_to_rcpointer;
29 typedef _cl_hashtable_iterator<cl_htentry_from_rcpointer2_to_rcpointer> cl_hashtable_from_rcpointer2_to_rcpointer_iterator;
31 struct cl_wht_from_rcpointer2_to_rcpointer : public cl_rcpointer {
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&);
38 cl_hashtable_from_rcpointer2_to_rcpointer_iterator iterator () const
39 { return ((cl_heap_weak_hashtable_from_rcpointer2_to_rcpointer*)pointer)->iterator(); }
41 cl_rcpointer * get (const cl_rcpointer& x, const cl_rcpointer& y) const;
43 void put (const cl_rcpointer& x, const cl_rcpointer& y, const cl_rcpointer& z) const;
48 #endif /* _CL_RCPOINTER2_HASHWEAK_RCPOINTER_H */