You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.5 KiB

25 years ago
25 years ago
25 years ago
25 years ago
  1. // cl_rcpointer hash tables
  2. #ifndef _CL_RCPOINTER_HASHWEAK_RCPOINTER_H
  3. #define _CL_RCPOINTER_HASHWEAK_RCPOINTER_H
  4. #include "cln/object.h"
  5. #include "cl_hash1weak.h"
  6. namespace cln {
  7. // Equality.
  8. static inline bool equal (const cl_rcpointer& x, const cl_rcpointer& y)
  9. { return (x.pointer == y.pointer); }
  10. // Hash code. Luckily objects don't move around in memory.
  11. inline unsigned long hashcode (const cl_rcpointer& x)
  12. { return (unsigned long)x.pointer; }
  13. typedef cl_htentry1<cl_rcpointer,cl_rcpointer> cl_htentry_from_rcpointer_to_rcpointer;
  14. typedef cl_heap_weak_hashtable_1<cl_rcpointer,cl_rcpointer> cl_heap_weak_hashtable_from_rcpointer_to_rcpointer;
  15. typedef _cl_hashtable_iterator<cl_htentry_from_rcpointer_to_rcpointer> cl_hashtable_from_rcpointer_to_rcpointer_iterator;
  16. struct cl_wht_from_rcpointer_to_rcpointer : public cl_rcpointer {
  17. // Constructors.
  18. cl_wht_from_rcpointer_to_rcpointer (cl_boolean (*maygc_htentry) (const cl_htentry_from_rcpointer_to_rcpointer&));
  19. cl_wht_from_rcpointer_to_rcpointer (const cl_wht_from_rcpointer_to_rcpointer&);
  20. // Assignment operators.
  21. cl_wht_from_rcpointer_to_rcpointer& operator= (const cl_wht_from_rcpointer_to_rcpointer&);
  22. // Iterator.
  23. cl_hashtable_from_rcpointer_to_rcpointer_iterator iterator () const
  24. { return ((cl_heap_weak_hashtable_from_rcpointer_to_rcpointer*)pointer)->iterator(); }
  25. // Lookup.
  26. cl_rcpointer * get (const cl_rcpointer& x) const;
  27. // Store.
  28. void put (const cl_rcpointer& x, const cl_rcpointer& y) const;
  29. };
  30. } // namespace cln
  31. #endif /* _CL_RCPOINTER_HASHWEAK_RCPOINTER_H */