diff --git a/id/id.c b/id/id.c new file mode 100644 index 0000000..d2c860c --- /dev/null +++ b/id/id.c @@ -0,0 +1,30 @@ +// +// id.c +// ZE-Standard-Libraries +// +// Created by 胡一兵 on 2018/7/25. +// Copyright © 2018年 ZE. All rights reserved. +// + +#include "id.h" + +void init_rand(void) { + srand((unsigned)time(NULL)); +} + +unsigned long long getId(void) { + int i; + unsigned long long id = 0; + id = ((rand() % 9) + 1); + for (i = 0; i < 15; i++) { + id *= 10; + id += rand() % 10; + } + return id; +} + +char *getS_id(void){ + + return NULL; +} + diff --git a/id/id.h b/id/id.h new file mode 100644 index 0000000..fe9981a --- /dev/null +++ b/id/id.h @@ -0,0 +1,22 @@ +// +// id.h +// ZE-Standard-Libraries +// +// Created by 胡一兵 on 2018/7/25. +// Copyright © 2018年 ZE. All rights reserved. +// + +#ifndef id_h +#define id_h + +#include +#include + +/*有关id的函数*/ +void init_rand(void); +unsigned long long getId(void); + +/*有关s_id函数*/ +char *getS_id(void); + +#endif /* id_h */ diff --git a/list/list.c b/list/list.c index 4afc44d..a4a2a08 100644 --- a/list/list.c +++ b/list/list.c @@ -121,21 +121,6 @@ int initMallocValueForNode(Node *p_node, int type, void *p_value) { return 0; } -void init_rand(void) { - srand((unsigned)time(NULL)); -} - -unsigned long long getId(void) { - int i; - unsigned long long id = 0; - id = ((rand() % 9) + 1); - for (i = 0; i < 15; i++) { - id *= 10; - id += rand() % 10; - } - return id; -} - int insertInHead(List *p_list, Node *p_node) { if (isListEmpty(p_list)) { p_list->head = p_node; diff --git a/list/list.h b/list/list.h index defec7f..f9496de 100644 --- a/list/list.h +++ b/list/list.h @@ -6,6 +6,7 @@ #include #include #include "../type/type.h" +#include "../id/id.h" typedef struct Node{ unsigned long long id;//唯一标识符 @@ -34,10 +35,6 @@ Node *initNode(void); int initMallocValueForNode(Node *,int,void *);//赋予已分配内存的值,并标明类型 -/*有关id的函数*/ -void init_rand(void); -unsigned long long getId(void); - /*插入函数*/ int insertInHead(List *p_list, Node *p_node); int insertInTail(List *p_list, Node *p_node); diff --git a/tree/tree_expand.h b/tree/tree_expand.h index a4236a2..bec0086 100644 --- a/tree/tree_expand.h +++ b/tree/tree_expand.h @@ -20,5 +20,8 @@ int printTNode(TNode *p_tnode, int priority); unsigned long long calTreeMemory(Tree *); int _doCalTreeMemory(TNode *p_tnode, unsigned long long height); + +List *treeToList(Tree *p_tree); + #endif diff --git a/type/type.h b/type/type.h index 199e088..cd7a83c 100644 --- a/type/type.h +++ b/type/type.h @@ -15,6 +15,8 @@ #define STRING 3 #define POINTER 4 #define LIST 5 +#define STACK 6 +#define TREE 7