VitroIO SDK
Software development kit for Vitro Shard.
Loading...
Searching...
No Matches
list.h
Go to the documentation of this file.
1#ifndef VITROIO_SDK_LIST_H
2#define VITROIO_SDK_LIST_H
3
4#include <cstddef>
5
6namespace vitroio
7{
8
9namespace sdk
10{
11
12namespace impl
13{
14
15template <typename T>
17{
20};
21
22template <typename T>
23class List
24{
25public:
27 {
28 first_ = NULL;
29 last_ = NULL;
30 }
31
33 {
34 ListNode<T>* node = first_;
35 ListNode<T>* nextNode;
36 while(node != NULL){
37 nextNode = node->next;
38 delete node;
39 node = nextNode;
40 }
41 }
42
43 bool isEmpty() const
44 {
45 return (first_ == NULL);
46 }
47
49 {
50 return first_;
51 }
52
54 {
55 return last_;
56 }
57
58 void pushBack(T value)
59 {
60 ListNode<T>* tmpNode = new ListNode<T>;
61 tmpNode->value = value;
62 tmpNode->next = NULL;
63 if(isEmpty()){
64 first_ = tmpNode;
65 last_ = tmpNode;
66 }
67 else{
68 last_->next = tmpNode;
69 last_ = tmpNode;
70 }
71 }
72
73private:
74 ListNode<T>* first_;
75 ListNode<T>* last_;
76};
77
78} // namespace impl
79
80} // namespace sdk
81
82} // namespace vitroio
83
84#endif // VITROIO_SDK_LIST_H
Definition: list.h:24
void pushBack(T value)
Definition: list.h:58
bool isEmpty() const
Definition: list.h:43
ListNode< T > * first()
Definition: list.h:48
List()
Definition: list.h:26
ListNode< T > * last()
Definition: list.h:53
~List()
Definition: list.h:32
The namespace contains all of components of vitro-shard-sdk and components based on the sdk....
Definition: can_layer.h:9
Definition: list.h:17
ListNode * next
Definition: list.h:19
T value
Definition: list.h:18