-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDLList.h
46 lines (37 loc) · 937 Bytes
/
DLList.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
//
// DLList.h
// DLList
//
// Created by Philip Leblanc on 2017-10-13.
// Copyright © 2017 Philip Leblanc. All rights reserved.
//
#ifndef DLList_h
#define DLList_h
#include <stdio.h>
struct Node {
int data = 0;
Node * next = nullptr;
Node * prev = nullptr;
};
class DLList {
private:
Node * head;
Node * tail;
Node * iter; //used as a helper node pointer to iterate / add / delete
int length;
void removeNode(Node *);
public:
DLList();
~DLList();
DLList(const DLList &list);
int inline size() {return length;}
void clear(); //empty the list
void addFront(int data);
void addBack(int data);
void removeFront();
void removeBack();
bool contains(int data); //search for data
void remove(int data); //remove the elements with data
void display(); // print out the list to the terminal starting from head
};
#endif /* DLList_h */