-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedList.cpp
More file actions
30 lines (28 loc) · 730 Bytes
/
LinkedList.cpp
File metadata and controls
30 lines (28 loc) · 730 Bytes
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
#include "LinkedList.h"
//Constructor for the linked list
LinkedList::LinkedList() : head(NULL) {}
//Destructor for the linked list`
LinkedList::~LinkedList() {
Destroy(head);
}
//Destructor helper for the linked list
void LinkedList::Destroy(Node *n) {
if (n != nullptr) {
Destroy(n->next);
delete n->data;
delete n;
}
}
// This function is used to insert a new TimeSeries object into the linked list
void LinkedList::handle_insert(TimeSeries* time_series) {
Node* newNode = new Node(time_series);
if (!head) {
head = newNode;
return;
}
Node* temp = head;
while (temp->next != nullptr) {
temp = temp->next;
}
temp->next = newNode;
}