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