]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/dictionary.hh
3cb1069b39e66c62df2f1ac553ed6bbac093ab6f
[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 "hash-table.hh"
17
18
19 unsigned int string_hash (String);
20
21
22 template<class V>
23 struct Dict_initialiser
24 {
25   char *key_;
26   V value_;
27 };
28
29
30 template<class V>
31 class Dictionary : public Hash_table<String, V>
32 {
33 public:
34   Dictionary ()
35     {
36       hash_func_ = string_hash;
37     }
38   Dictionary (Dict_initialiser<V> *p)
39     {
40       hash_func_ = string_hash;
41       for (Dict_initialiser<V> *q = p; q->key_; q++)
42         elem (q->key_) = q->value_;
43           
44     }
45
46   friend class Dictionary_iter<V>;
47 };
48
49
50 #endif // DICTIONARY_HH