]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/dictionary.hh
release: 1.3.148
[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 <map>
14
15
16 #include "string.hh"
17 #include "array.hh"
18
19
20 unsigned int string_hash (String);
21
22 template<class V>
23 struct Dict_initialiser
24 {
25   char *key_;
26   V value_;
27 };
28
29
30 /*
31   interface to STL function.
32  */
33 template<class V>
34 class Dictionary : public map<String, V>
35 {
36 public:
37   Dictionary ()
38     {
39     }
40   Dictionary (Dict_initialiser<V> *p)
41     {
42       hash_func_ = string_hash;
43       for (Dict_initialiser<V> *q = p; q->key_; q++)
44  (*this) [q->key_] = q->value_;
45           
46     }
47   bool elem_b (String s)
48   {
49     map<String,V>::const_iterator ki (find (s));
50     return ki != end ();
51   }
52   
53 };
54
55
56 #endif // DICTIONARY_HH