]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/dictionary-iter.hh
release: 1.1.18
[lilypond.git] / flower / include / dictionary-iter.hh
1 /*
2   dictionary-iter.hh -- declare Dictionary_iter
3
4   source file of the Flower Library
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef DICTIONARY_ITER_HH
11 #define DICTIONARY_ITER_HH
12
13 #include "dictionary.hh"
14
15 template<class K, class V>
16 class Hash_table_iter
17 {
18   Hash_table<K,V> *dict_l_;
19   int i;
20 public:
21   Hash_table_iter(Hash_table<K,V> const &dict)
22     {
23       i =0;
24       dict_l_ =(Hash_table<K,V> *) & dict;
25       next_used ();
26     }
27
28   bool ok ()
29     {
30       return i < dict_l_->fixed_p_->dict_arr_.size ();
31     }
32
33   void next_used ()
34     {
35       while (ok () && dict_l_->fixed_p_->dict_arr_[i].free_b_)
36         {
37           i ++;
38         }
39     }
40   void operator ++(int)
41     {
42       i++;
43       next_used ();
44     }
45
46   K key ()
47     {
48       return dict_l_->fixed_p_->dict_arr_[i].key_;
49     }
50   V val () 
51     {
52       return dict_l_->fixed_p_->dict_arr_[i].value_;      
53     }
54   V &val_ref ()
55     {
56       return dict_l_->fixed_p_->dict_arr_[i].value_;      
57     }
58 };
59
60 template<class V>
61 class Dictionary_iter<V> : public Hash_table_iter<String,V>
62 {
63 public:
64   Dictionary_iter (Dictionary<V> const &d)
65     : Hash_table_iter<String,V> (d)
66     {
67
68     }
69   
70   
71 };
72 #endif // Hash_table_ITER_HH