This commit is contained in:
Saturneic 2018-07-25 22:10:09 +08:00
parent fbb2a97ce5
commit 5ae6717bfc
6 changed files with 58 additions and 19 deletions

30
id/id.c Normal file
View File

@ -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;
}

22
id/id.h Normal file
View File

@ -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 <stdlib.h>
#include <time.h>
/*有关id的函数*/
void init_rand(void);
unsigned long long getId(void);
/*有关s_id函数*/
char *getS_id(void);
#endif /* id_h */

View File

@ -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;

View File

@ -6,6 +6,7 @@
#include <string.h>
#include <time.h>
#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);

View File

@ -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

View File

@ -15,6 +15,8 @@
#define STRING 3
#define POINTER 4
#define LIST 5
#define STACK 6
#define TREE 7