forked from aaronbloomfield/pdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathList.h
57 lines (51 loc) · 2.09 KB
/
List.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Filename: List.h
* Description: List class definition
* also includes the prototype for non-member function print()
*/
#ifndef LIST_H
#define LIST_H
#include <iostream>
#include "ListNode.h"
#include "ListItr.h"
using namespace std;
// When reading in ListItr.h first, it starts reading in this file
// before declaring that ListItr is a class. This file then include
// ListItr.h, but beacuse of the #ifndef LISTITR_H statement, the code
// in that file is not read. Thus, in this case, this List.h file
// will be read in, and will not know that ListItr is a class, which
// will cause compilation problems later on in this file. Got it?
// Isn't C++ fun???
class ListItr;
class List {
public:
List(); //Constructor
List(const List& source); //Copy Constructor
~List(); //Destructor
List& operator=(const List& source); //Equals Operator
bool isEmpty() const; //Returns true if empty; else false
void makeEmpty(); //Removes all items except blank head and tail
ListItr first(); //Returns an iterator that points to
//the ListNode in the first position
ListItr last(); //Returns an iterator that points to
//the ListNode in the last position
void insertAfter(int x, ListItr position);
//Inserts x after current iterator position p
void insertBefore(int x, ListItr position);
//Inserts x before current iterator position p
void insertAtTail(int x); //Insert x at tail of list
void remove(int x); //Removes the first occurrence of x
ListItr find(int x); //Returns an iterator that points to
// the first occurrence of x, else return a iterator to the dummy tail node
int size() const; //Returns the number of elements in the list
private:
ListNode *head, *tail; //indicates beginning and end of the list
int count; //#of elements in list
friend class ListItr;
};
// printList: non-member function prototype
void printList(List& source, bool direction);
//prints list forwards when direction is true
//or backwards when direction is false
#endif
/* end of List.h */