forked from aaronbloomfield/pdr
-
Notifications
You must be signed in to change notification settings - Fork 228
/
ListItr.h.html
54 lines (44 loc) · 3.82 KB
/
ListItr.h.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="GNU source-highlight
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite">
<title>ListItr.h</title>
</head>
<body style="background-color:white">
<pre><i><span style="color:#9A1900">/*</span></i>
<i><span style="color:#9A1900"> * Filename: ListItr.h</span></i>
<i><span style="color:#9A1900"> * Description: ListItr class definition</span></i>
<i><span style="color:#9A1900"> */</span></i>
<b><span style="color:#000080">#ifndef</span></b> LISTITR_H
<b><span style="color:#000080">#define</span></b> LISTITR_H
<b><span style="color:#000080">#include</span></b> <span style="color:#FF0000">"ListNode.h"</span>
<b><span style="color:#000080">#include</span></b> <span style="color:#FF0000">"List.h"</span>
<b><span style="color:#0000FF">class</span></b> <span style="color:#008080">ListItr</span> <span style="color:#FF0000">{</span>
<b><span style="color:#0000FF">public</span></b><span style="color:#990000">:</span>
<i><span style="color:#9A1900">// Constructors</span></i>
<b><span style="color:#000000">ListItr</span></b><span style="color:#990000">();</span>
<b><span style="color:#000000">ListItr</span></b><span style="color:#990000">(</span>ListNode<span style="color:#990000">*</span> theNode<span style="color:#990000">);</span>
<i><span style="color:#9A1900">// Returns true if the iterator is currently pointing past the end position</span></i>
<i><span style="color:#9A1900">// in the list (i.e., it's pointing to the dummy tail), else false</span></i>
<span style="color:#009900">bool</span> <b><span style="color:#000000">isPastEnd</span></b><span style="color:#990000">()</span> <b><span style="color:#0000FF">const</span></b><span style="color:#990000">;</span>
<i><span style="color:#9A1900">// Returns true if the iterator is currently pointing past (before) the first position</span></i>
<i><span style="color:#9A1900">// in list (i.e., it's pointing to the dummy head), else false</span></i>
<span style="color:#009900">bool</span> <b><span style="color:#000000">isPastBeginning</span></b><span style="color:#990000">()</span> <b><span style="color:#0000FF">const</span></b><span style="color:#990000">;</span>
<i><span style="color:#9A1900">// Advances `current` to the next position in the list (unless already past the end of the list)</span></i>
<span style="color:#009900">void</span> <b><span style="color:#000000">moveForward</span></b><span style="color:#990000">();</span>
<i><span style="color:#9A1900">// Moves `current` back to the previous position in the list (unless already past the beginning of the list)</span></i>
<span style="color:#009900">void</span> <b><span style="color:#000000">moveBackward</span></b><span style="color:#990000">();</span>
<i><span style="color:#9A1900">// Returns the value of the item in the current position of the list</span></i>
<span style="color:#009900">int</span> <b><span style="color:#000000">retrieve</span></b><span style="color:#990000">()</span> <b><span style="color:#0000FF">const</span></b><span style="color:#990000">;</span>
<b><span style="color:#0000FF">private</span></b><span style="color:#990000">:</span>
ListNode<span style="color:#990000">*</span> current<span style="color:#990000">;</span> <i><span style="color:#9A1900">// Holds the position in the list</span></i>
<b><span style="color:#0000FF">friend</span></b> <b><span style="color:#0000FF">class</span></b> <span style="color:#008080">List</span><span style="color:#990000">;</span> <i><span style="color:#9A1900">// List class needs access to "current"</span></i>
<span style="color:#FF0000">}</span><span style="color:#990000">;</span>
<b><span style="color:#000080">#endif</span></b>
</pre>
</body>
</html>