weak-table.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* classes: h_files */
  2. #ifndef SCM_WEAK_TABLE_H
  3. #define SCM_WEAK_TABLE_H
  4. /* Copyright (C) 2011, 2012 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #include "libguile/__scm.h"
  22. /* The weak table API is currently only used internally. We could make it
  23. public later, after some API review. */
  24. typedef enum {
  25. SCM_WEAK_TABLE_KIND_KEY,
  26. SCM_WEAK_TABLE_KIND_VALUE,
  27. SCM_WEAK_TABLE_KIND_BOTH,
  28. } scm_t_weak_table_kind;
  29. /* Function that returns nonzero if the given mapping is the one we are
  30. looking for. */
  31. typedef int (*scm_t_table_predicate_fn) (SCM k, SCM v, void *closure);
  32. /* Function to fold over the elements of a set. */
  33. typedef SCM (*scm_t_table_fold_fn) (void *closure, SCM k, SCM v, SCM result);
  34. SCM_INTERNAL SCM scm_c_make_weak_table (unsigned long k,
  35. scm_t_weak_table_kind kind);
  36. SCM_INTERNAL SCM scm_weak_table_p (SCM h);
  37. SCM_INTERNAL SCM scm_c_weak_table_ref (SCM table, unsigned long raw_hash,
  38. scm_t_table_predicate_fn pred,
  39. void *closure, SCM dflt);
  40. SCM_INTERNAL void scm_c_weak_table_put_x (SCM table, unsigned long raw_hash,
  41. scm_t_table_predicate_fn pred,
  42. void *closure, SCM key, SCM value);
  43. SCM_INTERNAL void scm_c_weak_table_remove_x (SCM table, unsigned long raw_hash,
  44. scm_t_table_predicate_fn pred,
  45. void *closure);
  46. SCM_INTERNAL SCM scm_weak_table_refq (SCM table, SCM key, SCM dflt);
  47. SCM_INTERNAL void scm_weak_table_putq_x (SCM table, SCM key, SCM value);
  48. SCM_INTERNAL void scm_weak_table_remq_x (SCM table, SCM key);
  49. SCM_INTERNAL void scm_weak_table_clear_x (SCM table);
  50. SCM_INTERNAL SCM scm_c_weak_table_fold (scm_t_table_fold_fn proc, void *closure,
  51. SCM init, SCM table);
  52. SCM_INTERNAL SCM scm_weak_table_fold (SCM proc, SCM init, SCM table);
  53. SCM_INTERNAL void scm_weak_table_for_each (SCM proc, SCM table);
  54. SCM_INTERNAL SCM scm_weak_table_map_to_list (SCM proc, SCM table);
  55. /* Legacy interface. */
  56. SCM_API SCM scm_make_weak_key_hash_table (SCM k);
  57. SCM_API SCM scm_make_weak_value_hash_table (SCM k);
  58. SCM_API SCM scm_make_doubly_weak_hash_table (SCM k);
  59. SCM_API SCM scm_weak_key_hash_table_p (SCM h);
  60. SCM_API SCM scm_weak_value_hash_table_p (SCM h);
  61. SCM_API SCM scm_doubly_weak_hash_table_p (SCM h);
  62. SCM_INTERNAL void scm_i_weak_table_print (SCM exp, SCM port, scm_print_state *pstate);
  63. SCM_INTERNAL void scm_weak_table_prehistory (void);
  64. SCM_INTERNAL void scm_init_weak_table (void);
  65. #endif /* SCM_WEAK_TABLE_H */
  66. /*
  67. Local Variables:
  68. c-file-style: "gnu"
  69. End:
  70. */