Voxeloop  0.1.0
Musical Loop Generation in Voxel World
LinkedList.hpp
Go to the documentation of this file.
1 #ifndef VOXELOOP_LINKEDLIST_HPP
2 #define VOXELOOP_LINKEDLIST_HPP
3 
4 template <class T> struct Node {
5  T data;
6  struct Node<T> *next;
7 };
8 
9 template <class T> class LinkedList {
10 public:
11  struct Node<T> *head;
12  LinkedList() { head = nullptr; }
13  void addData(T data) {
14  struct Node<T> *node = newNode(data);
15  struct Node<T> *temp = head;
16 
17  if (head == nullptr) {
18  head = node;
19  return;
20  }
21 
22  while (temp->next != nullptr) {
23  temp = temp->next;
24  }
25  temp->next = node;
26  }
27 
28 private:
29  struct Node<T> *newNode(T data) {
30  auto *node = new struct Node<T>;
31  node->data = data;
32  node->next = nullptr;
33  return node;
34  }
35 };
36 
37 #endif // VOXELOOP_LINKEDLIST_HPP
Definition: LinkedList.hpp:9
void addData(T data)
Definition: LinkedList.hpp:13
struct Node< T > * head
Definition: LinkedList.hpp:11
LinkedList()
Definition: LinkedList.hpp:12
struct Node< T > * newNode(T data)
Definition: LinkedList.hpp:29
Definition: LinkedList.hpp:4
struct Node< T > * next
Definition: LinkedList.hpp:6
T data
Definition: LinkedList.hpp:5