*** empty log message ***
[lilypond.git] / lily / include / scm-hash.hh
blob626ae3d7ae9155c614748e197049dfe64e62bfdc
1 /*
2 scm-hash.hh -- declare Scheme hasher.
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #ifndef SCM_HASH_HH
11 #define SCM_HASH_HH
14 #include "lily-guile.hh"
15 #include "smobs.hh"
18 /**
19 auto resizing hash table.
21 1. ALWAYS USE THIS AS VIA A POINTER, i.e.
23 class Foo {
24 Scheme_hash_table * tab;
27 and NOT
29 class Foo {
30 Scheme_hash_table tab;
34 2. UPON DESTRUCTION, DO
36 scm_gc_unprotect_object (tab->self_scm_);
40 class Scheme_hash_table
42 public:
43 bool try_retrieve (SCM key, SCM *val);
44 bool elem_b (SCM key) const;
46 /**
47 WARNING: putting something in assumes responsibility for cleaning
48 up. */
49 void set (SCM k, SCM v);
50 SCM get (SCM k) const;
51 void remove (SCM k);
52 Scheme_hash_table ();
53 void operator = (Scheme_hash_table const &);
54 Scheme_hash_table (Scheme_hash_table const &);
56 SCM to_alist () const;
57 private:
58 SCM hash_tab_;
59 unsigned elt_count_;
61 DECLARE_SMOBS (Scheme_hash_table,foo);
65 #endif /* SCM_HASH_HH */