-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.h
39 lines (29 loc) · 850 Bytes
/
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
#pragma once
#include "node.h"
/* PART B */
/* Stacks using Linked Lists */
/*
Linked Lists with Sentinels
[X]<->[7]<->[3]<->[2]<->[X]
The head and tails are dummy elements ([X]) that do not have valid values.
These are called sentinel elements.
*/
class List {
private:
int size;
Node* sentinel_head;
Node* sentinel_tail;
public:
List();
~List();
// Insert an element at the tail of the linked list
void insert(int v);
// Delete the tail of the linked list and return the value
// You need to delete the valid tail element, not the sentinel
int delete_tail();
// Return the size of the linked list
// Do not count the sentinel elements
int get_size();
// Return a pointer to the sentinel head of the linked list
Node* get_head();
};