]> www.ginac.de Git - cln.git/blob - src/base/hash/cl_rcpointer_hashweak_rcpointer.h
64-bit mingw port: In hash table routines, use 'intptr_t' instead of 'long'.
[cln.git] / src / base / hash / cl_rcpointer_hashweak_rcpointer.h
1 // cl_rcpointer hash tables
2
3 #ifndef _CL_RCPOINTER_HASHWEAK_RCPOINTER_H
4 #define _CL_RCPOINTER_HASHWEAK_RCPOINTER_H
5
6 #include "cln/object.h"
7
8 #include "base/hash/cl_hash1weak.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& x)
18 { return (uintptr_t)x.pointer; }
19
20 typedef cl_htentry1<cl_rcpointer,cl_rcpointer> cl_htentry_from_rcpointer_to_rcpointer;
21
22 typedef cl_heap_weak_hashtable_1<cl_rcpointer,cl_rcpointer> cl_heap_weak_hashtable_from_rcpointer_to_rcpointer;
23
24 typedef _cl_hashtable_iterator<cl_htentry_from_rcpointer_to_rcpointer> cl_hashtable_from_rcpointer_to_rcpointer_iterator;
25
26 struct cl_wht_from_rcpointer_to_rcpointer : public cl_rcpointer {
27         // Constructors.
28         cl_wht_from_rcpointer_to_rcpointer (bool (*maygc_htentry) (const cl_htentry_from_rcpointer_to_rcpointer&));
29         cl_wht_from_rcpointer_to_rcpointer (const cl_wht_from_rcpointer_to_rcpointer&);
30         // Assignment operators.
31         cl_wht_from_rcpointer_to_rcpointer& operator= (const cl_wht_from_rcpointer_to_rcpointer&);
32         // Iterator.
33         cl_hashtable_from_rcpointer_to_rcpointer_iterator iterator () const
34         { return ((cl_heap_weak_hashtable_from_rcpointer_to_rcpointer*)pointer)->iterator(); }
35         // Lookup.
36         cl_rcpointer * get (const cl_rcpointer& x) const;
37         // Store.
38         void put (const cl_rcpointer& x, const cl_rcpointer& y) const;
39 };
40
41 }  // namespace cln
42
43 #endif /* _CL_RCPOINTER_HASHWEAK_RCPOINTER_H */