📄 itemiterator.h.html
字号:
<html>
<head>
<title>itemiterator.h</title>
</head>
<body>
<pre> 1 #ifndef ITEMITERATOR_H
2 #define ITEMITERATOR_H
3
4 #include <vector>
5 #include "item.h"
6
7 <font color='#0000cc'>/**
8 An iterator through a collection of items
9 */</font>
10 class ItemIterator
11 {
12 public:
13 <font color='#0000cc'>/**
14 Constructs the iterator from a vector.
15 @param its a reference to a vector of Item pointers
16 */</font>
17 ItemIterator(vector<Item*>& its);
18 <font color='#0000cc'>/**
19 Gets the current item.
20 @return the current item pointer
21 */</font>
22 Item* get() const;
23 <font color='#0000cc'>/**
24 Advances to the next item.
25 */</font>
26 void next();
27 <font color='#0000cc'>/**
28 Tests whether there are more items.
29 @return true if no more items are available.
30 */</font>
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</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -