From 8f6da2622fc81fdeeca20f704c0ce5847c1a1b10 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Wed, 7 Feb 2018 20:09:44 +0800 Subject: [PATCH] Built the basement of the list. --- list/list.c | 14 ++++++++++++++ list/list.h | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/list/list.c b/list/list.c index e69de29..f964bb4 100644 --- a/list/list.c +++ b/list/list.c @@ -0,0 +1,14 @@ +/* ******************************************************** + * This file is used to test the header file(list.h). + * When the project is finished, this file will be deleted. + * This file create by saturneric at 20:04 on Feb 7th. + * *******************************************************/ + +#include +#include +#include "list.h" + +int main(int argc, char **argv){ + + return 0; +} diff --git a/list/list.h b/list/list.h index e69de29..ae912f5 100644 --- a/list/list.h +++ b/list/list.h @@ -0,0 +1,24 @@ +typedef struct Node{ + unsigned long int id; + void *value; + struct Node *next; + struct Node *front; +} Node; + +typedef struct List{ + Node *head; + Node *tail; + unsigned long int length; +} List; + +List *init_list(); +Node *init_node(); +int insertInHead(List *p_list, Node *p_node); +int insertInTail(List*p_list, Node *p_node); +int removeById(List *p_list, unsigned long id); +int removeByNode(List *p_list, Node *p_node); +int popFromHead(List *p_list); +int popFromTail(List *p_list); +unsigned long int len(List *p_list); +Node *findById(List *p_list, unsigned long int id); +Node *findByValue(List *p_list, char type[], void *value);