-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinkedList.h
88 lines (83 loc) · 1.92 KB
/
LinkedList.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* @file : LinkedList.h
* @author : Ethan Ward
* @date : 2015.02.12
* @brief: Creates Linked Lists, which are series of nodes. Adds and removes nodes to and from the front and back of the list. Searches the list for a value. Prints all the values in a list.
*/
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include <iostream>
#include "Node.h"
class LinkedList {
public:
/**
* @pre None
* @post Initializes a Linked List instance with the front set to nullptr and the size set to 0
* @return None
*/
LinkedList();
/**
* @pre A Linked List is being deleted
* @post Deletes every node in the linked list
* @return None
*/
~LinkedList();
/**
* @pre None
* @post None
* @return Returns true if the list is empty, false if it isn't
*/
bool isEmpty() const;
/**
* @pre None
* @post None
* @return Returns the size of the list.
*/
int size() const;
/**
* @pre None
* @post Searches through the linked list for the given value.
* @return Returns true if the list has the value, false if it doesn't.
*/
bool search(int value) const;
/**
* @pre None
* @post Goes through the linked list and prints out every value in it.
* @return None
*/
void printList() const;
/**
* @pre None
* @post Adds a node to the back of the list.
* @return None
*/
void addBack(int value);
/**
* @pre None
* @post Adds a node to the front of the list.
* @return None
*/
void addFront(int value);
/**
* @pre None
* @post Removes a node from the back of the list if possible.
* @return Returns true if the node was removed, false if it wasn't,
*/
bool removeBack();
/**
* @pre None
* @post Removes a node from the front of the list if possible.
* @return Returns true if the node was removed, false if it wasn't.
*/
bool removeFront();
/**
* @pre None
* @post Prints out a menu with all of the tasks that the class can do.
* @return None
*/
void printMenu();
private:
Node* m_front;
int m_size;
};
#endif