]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/scm-hash.hh
patch::: 1.3.59.uu2
[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--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef SCM_HASH_HH
11 #define SCM_HASH_HH
12
13
14 #include <map>
15
16 #include "lily-guile.hh"
17 #include "smobs.hh"
18
19
20 struct SCM_less
21 {
22   bool operator  () (SCM s1, SCM s2) const
23   {
24     return long(s1) < long (s2);
25   }
26 };
27
28 typedef map<SCM,SCM, SCM_less> Scm_stl_map;
29
30 /**
31    auto resizing hash table. This should come from GUILE.
32
33    ALWAYS USE THIS AS VIA A POINTER, i.e.
34
35    class Foo {
36     Scheme_hash_table * tab;
37    };
38
39    and NOT
40
41    class Foo {
42     Scheme_hash_table tab;
43    }
44  */
45 class Scheme_hash_table :  private Scm_stl_map
46 {
47 public:
48   bool try_retrieve (SCM key, SCM *val);
49   bool elem_b (SCM key) const;
50
51   /**
52      WARNING: putting something in assumes responsibility for cleaning
53      up.  */
54   void set (SCM k, SCM v);
55   SCM get (SCM k) const; 
56   
57   Scheme_hash_table ();
58   void operator = (Scheme_hash_table const &); 
59   Scheme_hash_table (Scheme_hash_table const &);
60   virtual ~Scheme_hash_table ();
61   DECLARE_SMOBS;
62   SCM to_alist () const;
63 };
64
65 #endif /* SCM_HASH_HH */
66