🎉 init: cmake build for data structures
This commit is contained in:
4
include/CMakeLists.txt
Normal file
4
include/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
target_sources(
|
||||
list
|
||||
PUBLIC list.h
|
||||
)
|
35
include/list.h
Normal file
35
include/list.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef __LIST__H__
|
||||
#define __LIST__H__
|
||||
|
||||
#include <cstddef>
|
||||
struct Node {
|
||||
size_t data_p;
|
||||
Node *next;
|
||||
};
|
||||
|
||||
class List {
|
||||
List();
|
||||
~List();
|
||||
void push_back(int data);
|
||||
void push_front(int data);
|
||||
void insert(int data, int index);
|
||||
void pop_back();
|
||||
void pop_front();
|
||||
void remove(int index);
|
||||
void print();
|
||||
int size();
|
||||
bool empty();
|
||||
void clear();
|
||||
int front();
|
||||
int back();
|
||||
|
||||
|
||||
private:
|
||||
Node *head_;
|
||||
Node *tail_;
|
||||
int count_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //!__LIST__H__
|
Reference in New Issue
Block a user