]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/scm-hash.hh
release: 1.3.39
[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 "hash-table.hh"
18 #include "smobs.hh"
19
20
21 struct SCM_less
22 {
23   bool operator  () (SCM s1, SCM s2) const
24   {
25     return long(s1) < long (s2);
26   }
27 };
28
29 typedef map<SCM,SCM, SCM_less> Scm_stl_map;
30
31 /**
32    auto resizing hash table. This should come from GUILE.
33  */
34 class Scheme_hash_table :  private Scm_stl_map
35 {
36 public:
37   bool try_retrieve (SCM key, SCM *val);
38   bool elem_b (SCM key) const;
39
40   /**
41      WARNING: putting something in assumes responsibility for cleaning
42      up.  */
43   void set (SCM k, SCM v);
44   SCM get (SCM k) const; 
45   
46   Scheme_hash_table ();
47   void operator = (Scheme_hash_table const &); 
48   Scheme_hash_table (Scheme_hash_table const &);
49   virtual ~Scheme_hash_table ();
50   DECLARE_SMOBS;
51   SCM to_alist () const;
52 };
53
54 #endif /* SCM_HASH_HH */
55