-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDList.h
67 lines (55 loc) · 1.22 KB
/
DList.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
58
59
60
61
62
63
64
65
66
67
// Greg Kaiser
//
// CS290 with Prof. Francis
// 4D Tetris
//
// DList.h
// Last modified: April 17, 1996
//
// (C) 1996 Board of Trustees University of Illinois
#ifndef _DLIST_H_
#define _DLIST_H_
#include <iostream>
#include "Asserts.h"
class Hyper;
template <class T>
struct Node
{
Node() {next = prev = NULL;};
~Node() {delete data; if (next != NULL) delete next;}
Node<T> *next,
*prev;
T *data;
};
template <class T>
class DList
{
friend int FindAboveW(DList<Hyper> *List, int wcoord);
friend int FindAtW(DList<Hyper> *List, int wcoord);
private:
Node<T> *head,
*tail,
*current;
public:
//constructors
DList();
DList(T *e);
~DList();
void Output();
//list manipulation
void InsertAfter(T *e);
void InsertBefore(T *e);
void Remove();
//current pointer adjustment
inline void Head() {current = head;};
inline void Tail() {current = tail;};
DList& operator++ (int);
DList& operator-- (int); //remember to use (*p)++, etc
//value retrieval
inline int NotEmpty() { return (head != NULL); }
inline T *Get() {return current->data;};
inline int EndOfList() {return current==tail;};
Node<T> *ReturnCurrent();
void ChangeCurrent(Node<T> *NewCurrent);
};
#endif