forked from aaronbloomfield/pdr
-
Notifications
You must be signed in to change notification settings - Fork 228
/
ListItr.h
40 lines (30 loc) · 1.09 KB
/
ListItr.h
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
/*
* Filename: ListItr.h
* Description: ListItr class definition
*/
#ifndef LISTITR_H
#define LISTITR_H
#include "ListNode.h"
#include "List.h"
class ListItr {
public:
// Constructors
ListItr();
ListItr(ListNode* theNode);
// Returns true if the iterator is currently pointing past the end position
// in the list (i.e., it's pointing to the dummy tail), else false
bool isPastEnd() const;
// Returns true if the iterator is currently pointing past (before) the first position
// in list (i.e., it's pointing to the dummy head), else false
bool isPastBeginning() const;
// Advances `current` to the next position in the list (unless already past the end of the list)
void moveForward();
// Moves `current` back to the previous position in the list (unless already past the beginning of the list)
void moveBackward();
// Returns the value of the item in the current position of the list
int retrieve() const;
private:
ListNode* current; // Holds the position in the list
friend class List; // List class needs access to "current"
};
#endif