1 #ifndef ITEMITERATOR_H
2 #define ITEMITERATOR_H
3
4 #include <vector>
5 #include "item.h"
6
7 /**
8 An iterator through a collection of items
9 */
10 class ItemIterator
11 {
12 public:
13 /**
14 Constructs the iterator from a vector.
15 @param its a reference to a vector of Item pointers
16 */
17 ItemIterator(vector<Item*>& its);
18 /**
19 Gets the current item.
20 @return the current item pointer
21 */
22 Item* get() const;
23 /**
24 Advances to the next item.
25 */
26 void next();
27 /**
28 Tests whether there are more items.
29 @return true if no more items are available.
30 */
31 bool is_done() const;
32 private:
33 const vector<Item*>& items;
34 int pos;
35 };
36
37 inline void ItemIterator::next()
38 {
39 pos++;
40 }
41
42 #endif