🎉 init: cmake build for data structures

This commit is contained in:
clzhao20
2024-04-07 18:44:19 +08:00
commit 8a80b3f8b9
7 changed files with 134 additions and 0 deletions

4
include/CMakeLists.txt Normal file
View File

@@ -0,0 +1,4 @@
target_sources(
list
PUBLIC list.h
)

35
include/list.h Normal file
View 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__