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