]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/scm-hash.hh
*** empty log message ***
[lilypond.git] / lily / include / scm-hash.hh
1 /*   
2   scm-hash.hh -- declare Scheme hasher.
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef SCM_HASH_HH
11 #define SCM_HASH_HH
12
13
14 #include "smobs.hh"
15
16
17 /**
18    auto resizing hash table. 
19
20    1. ALWAYS USE THIS AS VIA A POINTER, i.e.
21
22    class Foo {
23     Scheme_hash_table * tab;
24    };
25
26    and NOT
27
28    class Foo {
29     Scheme_hash_table tab;
30    }
31
32
33    2. UPON DESTRUCTION, DO
34
35    scm_gc_unprotect_object (tab->self_scm_);
36
37  */
38
39 class Scheme_hash_table
40 {  
41 public:
42   bool try_retrieve (SCM key, SCM *val);
43   bool contains (SCM key) const;
44
45   /**
46      WARNING: putting something in assumes responsibility for cleaning
47      up.  */
48   void set (SCM k, SCM v);
49   SCM get (SCM k) const; 
50   void remove (SCM k);
51   Scheme_hash_table ();
52   void operator = (Scheme_hash_table const &); 
53   Scheme_hash_table (Scheme_hash_table const &);
54
55   SCM to_alist () const;
56
57 private:
58   SCM hash_tab_;
59   unsigned elt_count_;
60   
61   DECLARE_SMOBS (Scheme_hash_table, foo);
62 };
63
64
65 #endif /* SCM_HASH_HH */
66