]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/dictionary.hh
release: 1.3.53
[lilypond.git] / flower / include / dictionary.hh
1 /*
2   dictionary.hh -- declare Dictionary
3
4   source file of the Flower Library
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef DICTIONARY_HH
11 #define DICTIONARY_HH
12
13 #include "string.hh"
14 #include "array.hh"
15
16 #include <map>
17
18 #include "hash-table.hh"
19
20
21 unsigned int string_hash (String);
22
23
24 template<class V>
25 struct Dict_initialiser
26 {
27   char *key_;
28   V value_;
29 };
30
31
32 /*
33   interface to STL function.
34  */
35 template<class V>
36 class Dictionary : public map<String, V>
37 {
38 public:
39   Dictionary ()
40     {
41     }
42   Dictionary (Dict_initialiser<V> *p)
43     {
44       hash_func_ = string_hash;
45       for (Dict_initialiser<V> *q = p; q->key_; q++)
46         (*this) [q->key_] = q->value_;
47           
48     }
49   bool elem_b (String s)
50   {
51     map<String,V>::const_iterator ki (find (s));
52     return ki != end ();
53   }
54   
55 };
56
57
58 #endif // DICTIONARY_HH