weak-set.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef SCM_WEAK_SET_H
  2. #define SCM_WEAK_SET_H
  3. /* Copyright 2011,2018
  4. Free Software Foundation, Inc.
  5. This file is part of Guile.
  6. Guile is free software: you can redistribute it and/or modify it
  7. under the terms of the GNU Lesser General Public License as published
  8. by the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Guile is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with Guile. If not, see
  16. <https://www.gnu.org/licenses/>. */
  17. #include "libguile/scm.h"
  18. /* The weak set API is currently only used internally. We could make it
  19. public later, after some API review. */
  20. /* Function that returns nonzero if the given object is the one we are
  21. looking for. */
  22. typedef int (*scm_t_set_predicate_fn) (SCM obj, void *closure);
  23. /* Function to fold over the elements of a set. */
  24. typedef SCM (*scm_t_set_fold_fn) (void *closure, SCM key, SCM result);
  25. SCM_INTERNAL SCM scm_c_make_weak_set (unsigned long k);
  26. SCM_INTERNAL SCM scm_weak_set_p (SCM h);
  27. SCM_INTERNAL SCM scm_c_weak_set_lookup (SCM set, unsigned long raw_hash,
  28. scm_t_set_predicate_fn pred,
  29. void *closure, SCM dflt);
  30. SCM_INTERNAL SCM scm_c_weak_set_add_x (SCM set, unsigned long raw_hash,
  31. scm_t_set_predicate_fn pred,
  32. void *closure, SCM obj);
  33. SCM_INTERNAL void scm_c_weak_set_remove_x (SCM set, unsigned long raw_hash,
  34. scm_t_set_predicate_fn pred,
  35. void *closure);
  36. SCM_INTERNAL SCM scm_weak_set_add_x (SCM set, SCM obj);
  37. SCM_INTERNAL SCM scm_weak_set_remove_x (SCM set, SCM obj);
  38. SCM_INTERNAL SCM scm_weak_set_clear_x (SCM set);
  39. SCM_INTERNAL SCM scm_c_weak_set_fold (scm_t_set_fold_fn proc, void *closure,
  40. SCM init, SCM set);
  41. SCM_INTERNAL SCM scm_weak_set_fold (SCM proc, SCM init, SCM set);
  42. SCM_INTERNAL SCM scm_weak_set_for_each (SCM proc, SCM set);
  43. SCM_INTERNAL SCM scm_weak_set_map_to_list (SCM proc, SCM set);
  44. SCM_INTERNAL void scm_i_weak_set_print (SCM exp, SCM port, scm_print_state *pstate);
  45. SCM_INTERNAL void scm_init_weak_set (void);
  46. #endif /* SCM_WEAK_SET_H */