forked from uva-cs/pdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListNode.h.html
47 lines (38 loc) · 2.84 KB
/
ListNode.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
<!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>ListNode.h</title>
</head>
<body style="background-color:white">
<pre><i><span style="color:#9A1900">/*</span></i>
<i><span style="color:#9A1900"> * Filename: ListNode.h</span></i>
<i><span style="color:#9A1900"> * Description: ListNode class definition</span></i>
<i><span style="color:#9A1900"> */</span></i>
<b><span style="color:#000080">#ifndef</span></b> LISTNODE_H
<b><span style="color:#000080">#define</span></b> LISTNODE_H
<b><span style="color:#000080">#include</span></b> <span style="color:#FF0000"><iostream></span>
<i><span style="color:#9A1900">// next line needed because NULL is part of std namespace</span></i>
<b><span style="color:#0000FF">using</span></b> <b><span style="color:#0000FF">namespace</span></b> std<span style="color:#990000">;</span>
<b><span style="color:#0000FF">class</span></b> <span style="color:#008080">ListNode</span> <span style="color:#FF0000">{</span>
<b><span style="color:#0000FF">public</span></b><span style="color:#990000">:</span>
<b><span style="color:#000000">ListNode</span></b><span style="color:#990000">();</span> <i><span style="color:#9A1900">// Constructor</span></i>
<b><span style="color:#0000FF">private</span></b><span style="color:#990000">:</span>
<span style="color:#009900">int</span> value<span style="color:#990000">;</span> <i><span style="color:#9A1900">// The value of the node!</span></i>
<span style="color:#008080">ListNode</span> <span style="color:#990000">*</span>next<span style="color:#990000">,</span> <span style="color:#990000">*</span>previous<span style="color:#990000">;</span> <i><span style="color:#9A1900">// For doubly linked lists</span></i>
<i><span style="color:#9A1900">// List needs to be able to access/change ListNode's next and</span></i>
<i><span style="color:#9A1900">// previous pointers</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">// ListItr needs access to value</span></i>
<b><span style="color:#0000FF">friend</span></b> <b><span style="color:#0000FF">class</span></b> <span style="color:#008080">ListItr</span><span style="color:#990000">;</span>
<i><span style="color:#9A1900">// Not writing a destructor is fine in this case since there is no</span></i>
<i><span style="color:#9A1900">// dynamically allocated memory in this class.</span></i>
<span style="color:#FF0000">}</span><span style="color:#990000">;</span>
<b><span style="color:#000080">#endif</span></b>
</pre>
</body>
</html>