]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/dictionary-iter.hh
release: 1.0.17
[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
16
17 #include "dictionary.hh"
18
19 template<class V>
20 class Dictionary_iter
21 {
22   Dictionary<V> *dict_l_;
23   int i;
24 public:
25   Dictionary_iter(Dictionary<V> const &dict)
26     {
27       i =0;
28       dict_l_ =(Dictionary<V> *) & dict;
29       next_used ();
30     }
31
32   bool ok ()
33     {
34       return i < dict_l_->fixed_p_->dict_arr_.size ();
35     }
36
37   void next_used ()
38     {
39       while (ok () && dict_l_->fixed_p_->dict_arr_[i].free_b_)
40         {
41           i ++;
42         }
43     }
44   void operator ++(int)
45     {
46       i++;
47       next_used ();
48     }
49
50   String key ()
51     {
52       return dict_l_->fixed_p_->dict_arr_[i].name_;
53     }
54   V val ()
55     {
56       return dict_l_->fixed_p_->dict_arr_[i].value_;      
57     }
58 };
59
60 #endif // DICTIONARY_ITER_HH