Add and Fixed.

This commit is contained in:
Saturneic 2018-07-30 17:45:33 +08:00
parent 5ae6717bfc
commit 667e48801d
16 changed files with 344 additions and 65 deletions

View File

@ -0,0 +1,9 @@
//
// communicate.c
// ZE-Standard-Libraries
//
// Created by 胡一兵 on 2018/7/25.
// Copyright © 2018年 ZE. All rights reserved.
//
#include "communicate.h"

14
communicate/communicate.h Normal file
View File

@ -0,0 +1,14 @@
//
// communicate.h
// ZE-Standard-Libraries
//
// Created by 胡一兵 on 2018/7/25.
// Copyright © 2018年 ZE. All rights reserved.
//
#ifndef communicate_h
#define communicate_h
#endif /* communicate_h */

View File

@ -1 +1 @@
#include "graph.h"
#include "graph.h"

View File

@ -4,14 +4,14 @@
#include "../list/list_expand.h"
typedef struct GNode{
unsigned long long id;
SID *s_id;
void *value;
List *routes;
int if_setValue;
}GNode;
typedef struct route{
unsigned long long id;
SID *s_id;
double distance;
int if_setValue;
GNode from, to;

209
id/id.c
View File

@ -23,8 +23,211 @@ unsigned long long getId(void) {
return id;
}
char *getS_id(void){
return NULL;
SID *initS_id(unsigned int deep_level){
SID *p_sid = (SID *)malloc(sizeof(SID));
p_sid->type = VOID;
p_sid->deep = deep_level;
p_sid->value = NULL;
p_sid->value_deeper = NULL;
p_sid->value_deepest = NULL;
if (deep_level > 0) p_sid->value = (unsigned int (*)[DEEPC_LEN])malloc(sizeof(unsigned int)*DEEPC_LEN);
if (deep_level > 1) p_sid->value_deeper = (unsigned int (*)[DEEPB_LEN])malloc(sizeof(unsigned int)*DEEPB_LEN);
if (deep_level > 2) p_sid->value_deepest = (unsigned int (*)[DEEPA_LEN])malloc(sizeof(unsigned int)*DEEPA_LEN);
return p_sid;
}
SID *getS_id(unsigned int type, unsigned int deep_level){
SID *p_sid = (SID *)malloc(sizeof(SID));
p_sid->type = type;
p_sid->deep = deep_level;
p_sid->value = NULL;
p_sid->value_deeper = NULL;
p_sid->value_deepest = NULL;
if(deep_level > 0){
p_sid->value = (unsigned int (*)[DEEPC_LEN])malloc(sizeof(unsigned int)*DEEPC_LEN);
for(int i = 0; i < DEEPC_LEN; i++) (*p_sid->value)[i] = rand()%65535;
if(deep_level > 1){
p_sid->value_deeper = (unsigned int (*)[DEEPB_LEN])malloc(sizeof(unsigned int)*DEEPB_LEN);
for(int i = 0; i < DEEPB_LEN; i++) (*p_sid->value_deeper)[i] = rand()%65535;
}
if (deep_level > 2) {
p_sid->value_deepest = (unsigned int (*)[DEEPA_LEN])malloc(sizeof(unsigned int)*DEEPA_LEN);
for(int i = 0; i < DEEPA_LEN; i++) (*p_sid->value_deepest)[i] = rand()%65535;
}
}
return p_sid;
}
int fitS_id(const SID *fs_id, const SID *ss_id){
if(fs_id->type == ss_id->type){
if(fs_id->deep == ss_id->deep){
if (fs_id->deep > 0)
for(int i = 0; i < DEEPC_LEN; i++){
if((*fs_id->value)[i] == (*ss_id->value)[i]) continue;
else if((*fs_id->value)[i] > (*ss_id->value)[i]) return 1;
else return -1;
}
if (fs_id->deep > 1)
for(int i = 0; i < DEEPB_LEN; i++){
if((*fs_id->value_deeper)[i] == (*ss_id->value_deeper)[i]) continue;
else if((*fs_id->value_deeper)[i] > (*ss_id->value_deeper)[i]) return 1;
else return -1;
}
if (fs_id->deep > 2)
for(int i = 0; i < DEEPA_LEN; i++){
if((*fs_id->value_deepest)[i] == (*ss_id->value_deepest)[i]) continue;
else if((*fs_id->value_deepest)[i] > (*ss_id->value_deepest)[i]) return 1;
else return -1;
}
}
else{
if(fs_id->deep > ss_id->deep) return 1;
else return -1;
}
}
else{
if (fs_id->type > ss_id->type) return 1;
else return -1;
}
return 0;
}
int simFitS_id(const SID *fs_id, const SID *ss_id){
return !fitS_id(fs_id, ss_id);
}
char *s_idToASCIIString(const SID *s_id){
char *string = NULL;
int deep_len = 0, temp, buff_count, string_count;
unsigned int buff[DATA_BIT];
if(s_id->deep > 0){
if (s_id->deep == DEEPC){
string = (char *) malloc(sizeof(char) * (DEEPC_LEN + 1) * DATA_BIT + 1);
deep_len = DEEPC_LEN + 1;
deep_len *= DATA_BIT;
}
else if (s_id->deep == DEEPB){
string = (char *) malloc(sizeof(char) * (DEEPC_LEN + DEEPB_LEN + 1) * DATA_BIT + 1);
deep_len = DEEPC_LEN + DEEPB_LEN + 1;
deep_len *= DATA_BIT;
}
else{
string = (char *)malloc(sizeof(char) * (DEEPC_LEN + DEEPB_LEN + DEEPA_LEN + 1) * DATA_BIT + 1);
deep_len = DEEPC_LEN + DEEPB_LEN + DEEPA_LEN + 1;
deep_len *= DATA_BIT;
}
string[deep_len] = '\0';
temp = s_id->type;
buff_count = DATA_BIT - 1;
for (int i = 0; i < DATA_BIT; i++) buff[i] = 0;
while(buff_count >= 0){
buff[buff_count] = temp % 10;
string[buff_count] = buff[buff_count] + 48;
temp /= 10;
buff_count--;
}
deep_len -= DATA_BIT;
for(int i = 0; i < DEEPC_LEN; i++){
temp = (*s_id->value)[i];
for (int i = 0; i < DATA_BIT; i++) buff[i] = 0;
string_count = TYPE_LEN + (i) * 5;
buff_count = DATA_BIT - 1;
while (buff_count >= 0) {
buff[buff_count] = temp % 10;
temp /= 10;
buff_count--;
}
for(int i = DATA_BIT - 1; i >= 0; i--) string[string_count + i] = buff[i] + 48;
}
deep_len -= DEEPC_LEN * DATA_BIT;
if(deep_len > 0)
for(int i = 0; i < DEEPB_LEN; i++){
temp = (*s_id->value_deeper)[i];
for (int i = 0; i < DATA_BIT; i++) buff[i] = 0;
string_count = TYPE_LEN + DEEPC_LEN * DATA_BIT + (i) * DATA_BIT;
buff_count = DATA_BIT - 1;
while (buff_count >= 0) {
buff[buff_count] = temp % 10;
temp /= 10;
buff_count--;
}
for(int i = DATA_BIT - 1; i >= 0; i--) string[string_count + i] = buff[i] + 48;
}
deep_len -= DEEPB_LEN * DATA_BIT;
if(deep_len > 0)
for(int i = 0; i < DEEPA_LEN; i++){
temp = (*s_id->value_deepest)[i];
for (int i = 0; i < DATA_BIT; i++) buff[i] = 0;
string_count = TYPE_LEN + (DEEPC_LEN + DEEPB_LEN) * DATA_BIT + (i) * DATA_BIT;
buff_count = DATA_BIT - 1;
while (buff_count >= 0) {
buff[buff_count] = temp % 10;
string[string_count] = buff[buff_count] + 48;
temp /= 10;
buff_count--;
}
for(int i = DATA_BIT - 1; i >= 0; i--) string[string_count + i] = buff[i] + 48;
}
printf("%s",string);
return string;
}
else{
return NULL;
}
}
SID *asciiStringToS_id(const char *string){
SID *s_id = NULL;
unsigned long long string_len = strlen(string);
unsigned int buff[string_len - 1];
for(int i = 0; i < string_len; i++){
buff[i] = string[i] - 48;
}
if (string_len == 25) s_id = initS_id(1);
else if (string_len == 65) s_id = initS_id(2);
else if (string_len == 225) s_id = initS_id(3);
else return NULL;
for (int i = 0; i < 5; i++){
s_id->type += buff[i] ;
s_id->type *= 10;
}
s_id->type /= 10;
if (string_len >= 25){
for(int i = 0; i < DEEPC_LEN; i++){
(*s_id->value)[i] = 0;
for (int j = 0; j < 5; j++){
(*s_id->value)[i] += (int)buff[5 + i * 5 + j];
(*s_id->value)[i] *= 10;
}
(*s_id->value)[i] /= 10;
}
}
if (string_len >= 65){
for(int i = 0; i < DEEPB_LEN; i++){
(*s_id->value_deeper)[i] = 0;
for (int j = 0; j < 5; j++){
(*s_id->value_deeper)[i] += buff[25 + i * 5 + j];
(*s_id->value_deeper)[i] *= 10;
}
(*s_id->value_deeper)[i] /= 10;
}
}
if (string_len >= 225){
for(int i = 0; i < DEEPA_LEN; i++){
(*s_id->value_deepest)[i] = 0;
for (int j = 0; j < 5; j++){
(*s_id->value_deepest)[i] += buff[65 + i * 5 + j];
(*s_id->value_deepest)[i] *= 10;
}
(*s_id->value_deepest)[i] /= 10;
}
}
return s_id;
}

21
id/id.h
View File

@ -9,14 +9,33 @@
#ifndef id_h
#define id_h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "../type/type.h"
typedef struct s_id{
unsigned int type;
unsigned int (*value)[DEEPC_LEN];//4
unsigned int (*value_deeper)[DEEPB_LEN];//8
unsigned int (*value_deepest)[DEEPA_LEN];//32
unsigned int deep;
}SID;
/*有关id的函数*/
void init_rand(void);
unsigned long long getId(void);
/*有关s_id函数*/
char *getS_id(void);
SID *getS_id(unsigned int type ,unsigned int deep_level);
int fitS_id(const SID *fs_id, const SID *ss_id);
int simFitS_id(const SID *fs_id, const SID *ss_id);
char *s_idToASCIIString(const SID *s_id);
SID *asciiStringToS_id(const char *string);
SID *initS_id(unsigned int deep_level);
#endif /* id_h */

View File

@ -83,6 +83,7 @@ Node *initNode(void) {
Node *p_node = (Node *)malloc(sizeof(Node));
Node *prec_node = NULL;
p_node->id = getId();
p_node->s_id = getS_id(LIST_NODE, 2);
p_node->if_malloc = 0;
p_node->next = NULL;
p_node->last = NULL;
@ -101,6 +102,7 @@ List *initList(void) {
Node *p_node;
List *p_list = (List *)malloc(sizeof(List));
p_list->id = getId();
p_list->s_id = getS_id(LIST, 1);
p_list->head = NULL;
p_list->tail = NULL;
p_list->length = 0;
@ -114,7 +116,7 @@ List *initList(void) {
return p_list;
}
int initMallocValueForNode(Node *p_node, int type, void *p_value) {
int initMallocValueForNode(Node *p_node, unsigned int type, void *p_value) {
p_node->if_malloc = 1;
p_node->type = type;
p_node->value = p_value;
@ -212,12 +214,12 @@ unsigned long long len(List *p_list) {
return p_list->length;
}
int removeById(List *p_list, unsigned long long id) {
int removeById(List *p_list, const SID *s_id) {
Node *tmp = p_list->head;
if (isListEmpty(p_list))
return -1;
do {
if (tmp->id == id) {
if (simFitS_id(tmp->s_id, s_id)) {
if (tmp != p_list->head) {
tmp->last->next = tmp->next;
}
@ -298,13 +300,13 @@ int popFromTail(List *p_list) {
}
/*该函数算法需要改进*/
Node *findByIdForNode(List *p_list, const unsigned long long id) {
Node *findByIdForNode(List *p_list, const SID *s_id) {
Node *ph_node = p_list->head;
Node *pt_node = p_list->tail;
int direction = 0;
while (ph_node != pt_node) {
if (direction == 0) {
if (ph_node->id == id) {
if (simFitS_id(ph_node->s_id, s_id)) {
return ph_node;
}
else {
@ -313,7 +315,7 @@ Node *findByIdForNode(List *p_list, const unsigned long long id) {
direction = 1;
}
else {
if (pt_node->id == id) {
if (simFitS_id(pt_node->s_id, s_id)) {
return pt_node;
}
else {
@ -325,7 +327,7 @@ Node *findByIdForNode(List *p_list, const unsigned long long id) {
}
Node *findByValue(List *p_list, int type, const void *value) {
Node *findByValue(List *p_list, unsigned int type, const void *value) {
Node *p_node = p_list->head;
while (p_node != NULL) {
if (p_node->type != type) {
@ -360,7 +362,7 @@ Node *findByValue(List *p_list, int type, const void *value) {
return NULL;
}
List *mply_findByValue(List *p_list, int type, const void *value) {
List *mply_findByValue(List *p_list, unsigned int type, const void *value) {
List *f_list = initList();
Node *p_node = p_list->head;
while (p_node != NULL) {

View File

@ -10,9 +10,11 @@
typedef struct Node{
unsigned long long id;//唯一标识符
SID *s_id;
void *value;
int if_malloc;//记录是否已经初始化值
int type;//记录值的类型
_Bool if_malloc;//记录是否已经初始化值
_Bool if_sid;
unsigned int type;//记录值的类型
struct Node *next;
struct Node *last;
} Node;
@ -20,6 +22,7 @@ typedef struct Node{
typedef struct List{
unsigned long long id;//唯一标识符
SID *s_id;
Node *head;
Node *tail;
unsigned long long length;//链表长度
@ -33,7 +36,7 @@ int releaseAllForNode(void);//安全模式最后调用的函数
List *initList(void);
Node *initNode(void);
int initMallocValueForNode(Node *,int,void *);//赋予已分配内存的值,并标明类型
int initMallocValueForNode(Node *,unsigned int,void *);//赋予已分配内存的值,并标明类型
/*插入函数*/
int insertInHead(List *p_list, Node *p_node);
@ -46,16 +49,16 @@ int exchangeLocation(Node *p_node,Node *t_node);
Node *copyNode(Node *);
/*移除函数*/
int removeById(List *p_list, unsigned long long id);
int removeById(List *p_list, const SID *s_id);
int removeByNode(List *p_list, Node *p_node);
int popFromHead(List *p_list);
int popFromTail(List *p_list);
unsigned long long len(List *p_list);//查看链表的长度
Node *findByIdForNode(List *p_list, const unsigned long long id);//通过id查找目标链表中的匹配节点
Node *findByValue(List *p_list, int type, const void *value);//通过值来查找目标链表中的匹配节点
List *mply_findByValue(List *p_list, int type, const void *value);//寻找多个值匹配的节点
Node *findByIdForNode(List *p_list, const SID *s_id);//通过id查找目标链表中的匹配节点
Node *findByValue(List *p_list, unsigned int type, const void *value);//通过值来查找目标链表中的匹配节点
List *mply_findByValue(List *p_list, unsigned int type, const void *value);//寻找多个值匹配的节点
int releaseList(List *p_list);//释放List并可选择是否释放中所有的其中的Node
int releaseListForSingle(List *p_list);//单独释放List

View File

@ -50,7 +50,7 @@ Node *findByIndexForNode(List *p_list, unsigned long long m_index) {
return p_node;
}
int listThrough(List *p_list, int(*p_func)(int, void *)) {
int listThrough(List *p_list, int(*p_func)(unsigned int, void *)) {
Node *p_node = p_list->head;
while (p_node != NULL) {
if (p_node->if_malloc == 1) {

View File

@ -35,7 +35,7 @@ double getByDoubleForNode(Node *);//直接得到节点的值
char *getByStringForNode(Node *);//直接得到节点的值
void *getByPointerForNode(Node *);//直接得到节点的值
unsigned long long getIndexByNode(List *p_list,Node *p_node);
int listThrough(List *p_list, int (*p_func)(int , void *));//遍历链表并不断调用目标函数。目标函数将接受节点储存值的指针及其类型。
int listThrough(List *p_list, int (*p_func)(unsigned int type, void *value));//遍历链表并不断调用目标函数。目标函数将接受节点储存值的指针及其类型。
unsigned long long calListMemory(List *);

View File

@ -3,6 +3,7 @@
Stack *initStack(void) {
Stack *p_stack = (Stack *)malloc(sizeof(Stack));
p_stack->id = getId();
p_stack->s_id = getS_id(STACK, 1);
p_stack->length = 0;
p_stack->top = NULL;
return p_stack;
@ -11,6 +12,7 @@ Stack *initStack(void) {
SNode *initSNode(void) {
SNode *p_snode = (SNode *)malloc(sizeof(SNode));
p_snode->id = getId();
p_snode->s_id = getS_id(STACK_NODE, 2);
p_snode->if_malloc = 0;
p_snode->next = NULL;
p_snode->value = NULL;
@ -60,7 +62,7 @@ int releaseSNode(SNode *p_snode) {
return 0;
}
int initMallocValueForSNode(SNode *p_snode, int type, void *value) {
int initMallocValueForSNode(SNode *p_snode, unsigned int type, void *value) {
p_snode->if_malloc = 1;
p_snode->type = type;
p_snode->value = value;

View File

@ -6,21 +6,25 @@
typedef struct stack_node{
unsigned long long id;
int if_malloc;
int type;
SID *s_id;
_Bool if_malloc;
_Bool if_sid;
unsigned int type;
void *value;
struct stack_node *next;
} SNode;
typedef struct stack{
unsigned long long id;
SID *s_id;
unsigned long long length;
SNode *top;
_Bool if_sid;
} Stack;
Stack *initStack(void);
SNode *initSNode(void);
int initMallocValueForSNode(SNode *p_snode, int type, void *value);
int initMallocValueForSNode(SNode *p_snode, unsigned int type, void *value);
SNode *popStack(Stack *p_stack);
int pushStack(Stack *p_stack, SNode *p_snode);

8
test.c
View File

@ -3,7 +3,6 @@
int list(void) {
List *t_list, *m_list;;
init_rand();
safeModeForNode(1);
t_list = initList();
@ -83,7 +82,12 @@ int stack(void) {
int main(int argc, char **argv) {
tree();
//tree();
init_rand();
SID *p_sid = getS_id(LIST_NODE, 3);
char *string = s_idToASCIIString(p_sid);
SID *t_sid = asciiStringToS_id(string);
int if_same = simFitS_id(p_sid, t_sid);
getchar();
return 0;
}

View File

@ -1,7 +1,7 @@
#include"tree.h"
static unsigned long long target_id = 0;
static TNode *target_value_id = NULL;
static SID *target_sid = NULL;
static TNode *target_value_sid = NULL;
static int if_safeModeForTree = 0;
int safeModeForTree(int ifon) {
@ -31,7 +31,8 @@ int safeModeForTree(int ifon) {
TNode *initTNode(void) {
Node *s_node;
TNode *p_tnode = (TNode *)malloc(sizeof(TNode));
p_tnode->id = getId();
p_tnode->id = getId();
p_tnode->s_id = getS_id(TREE_NODE, 2);
p_tnode->child_num = 0;
p_tnode->father = NULL;
p_tnode->if_malloc = 0;
@ -60,7 +61,8 @@ TNode *initTNode(void) {
Tree *initTree(void) {
Node *s_node;
Tree *p_tree = (Tree *)malloc(sizeof(Tree));
p_tree->id = getId();
p_tree->id = getId();
p_tree->s_id = getS_id(TREE, 1);
p_tree->root = NULL;
if (if_safeModeForTree) {
if (if_safeModeForNode) {
@ -80,7 +82,7 @@ Tree *initTree(void) {
return p_tree;
}
int *initMallocValueForTNode(TNode *p_tnode, int type, void *value) {
int *initMallocValueForTNode(TNode *p_tnode, unsigned int type, void *value) {
p_tnode->type = type;
p_tnode->value = value;
p_tnode->if_malloc = 1;
@ -144,22 +146,22 @@ int removeChildInRight(TNode *p_tnode) {
}
TNode *getChildById(TNode *p_tnode, unsigned long long id) {
TNode *getChildById(TNode *p_tnode, const SID *s_id) {
List *p_home = p_tnode->home;
target_id = 0;
target_value_id = NULL;
target_sid = NULL;
target_value_sid = NULL;
listThrough(p_home, _dogetChildById);
if (target_value_id != NULL) {
return target_value_id;
if (target_value_sid != NULL) {
return target_value_sid;
}
return NULL;
}
int _dogetChildById(int type, void *value) {
int _dogetChildById(unsigned int type, void *value) {
if (type == POINTER) {
TNode *p_tode = (TNode *)value;
if (p_tode->id == target_id) {
target_value_id = p_tode;
if (simFitS_id(p_tode->s_id, target_sid)) {
target_value_sid = p_tode;
return -1;
}
}
@ -170,7 +172,7 @@ static int target_type = VOID;
static void *target_value = NULL;
static TNode *target_value_value = NULL;
TNode *getChildByValue(TNode *p_tnode, int type, void *value) {
TNode *getChildByValue(TNode *p_tnode, unsigned int type, void *value) {
List *p_home = p_tnode->home;
target_value = value;
target_type = type;
@ -182,7 +184,7 @@ TNode *getChildByValue(TNode *p_tnode, int type, void *value) {
return NULL;
}
int _dogetChildByValue(int type, void *value) {
int _dogetChildByValue(unsigned int type, void *value) {
if (type == target_type) {
TNode *p_tode = (TNode *)value;
if (target_type == INT) {
@ -221,12 +223,12 @@ int _dogetChildByValue(int type, void *value) {
return 0;
}
int removeChildById(TNode *p_tnode, unsigned long long id) {
TNode *t_tnode = getChildById(p_tnode, id);
int removeChildById(TNode *p_tnode, const SID *s_id) {
TNode *t_tnode = getChildById(p_tnode, s_id);
if (t_tnode != NULL) {
TNode *p_fnode = t_tnode->father;
p_fnode->child_num--;
removeById(p_fnode->home, t_tnode->room->id);
removeById(p_fnode->home, t_tnode->room->s_id);
releaseOnlyNode(t_tnode->room);
t_tnode->room = NULL;
return 0;
@ -234,12 +236,12 @@ int removeChildById(TNode *p_tnode, unsigned long long id) {
return -1;
}
int removeChildByValue(TNode *p_tnode, int type, void *value) {
int removeChildByValue(TNode *p_tnode, unsigned int type, void *value) {
TNode *t_tnode = getChildByValue(p_tnode, type, value);
if (t_tnode != NULL) {
TNode *p_fnode = t_tnode->father;
p_fnode->child_num--;
removeById(p_fnode->home, t_tnode->room->id);
removeById(p_fnode->home, t_tnode->room->s_id);
releaseOnlyNode(t_tnode->room);
t_tnode->room = NULL;
return 0;
@ -282,7 +284,7 @@ int removeChildByIndex(TNode *p_tnode, unsigned long long index) {
if (t_tnode != NULL) {
TNode *p_fnode = t_tnode->father;
p_fnode->child_num--;
removeById(p_fnode->home, t_tnode->room->id);
removeById(p_fnode->home, t_tnode->room->s_id);
releaseOnlyNode(t_tnode->room);
t_tnode->room = NULL;
return 0;
@ -373,7 +375,7 @@ int releaseTNode(TNode *p_tnode) {
if (p_tnode->child_num == 0) {
releaseList(p_tnode->home);
if (p_tnode->father != NULL) {
removeChildById(p_tnode->father, p_tnode->id);
removeChildById(p_tnode->father, p_tnode->s_id);
}
if (p_tnode->type != POINTER) {
if (p_tnode->type == LIST) {

View File

@ -6,19 +6,23 @@
typedef struct tree_node
{
unsigned long long id;
unsigned long long id;
SID *s_id;
List *home;
struct tree_node *father;
Node *room;
unsigned long long child_num;
int type;
unsigned int type;
void *value;
int if_malloc;
_Bool if_malloc;
_Bool if_sid;
}TNode;
typedef struct tree
{
unsigned long long id;
unsigned long long id;
SID *s_id;
_Bool if_sid;
TNode *root;
}Tree;
@ -28,7 +32,7 @@ int releaseAllForTree(void);
TNode *initTNode(void);
Tree *initTree(void);
int *initMallocValueForTNode(TNode *p_tnode, int type, void *value);
int *initMallocValueForTNode(TNode *p_tnode, unsigned int type, void *value);
int addChildInLeft(TNode *f_tnode, TNode *c_tnode);
int addChildInRight(TNode *f_tnode, TNode *c_tnode);
@ -36,19 +40,19 @@ TNode *getBrotherInLeft(TNode *p_tnode);
TNode *getBrotherInRight(TNode *p_node);
int removeChildInLeft(TNode *p_tnode);
int removeChildInRight(TNode *p_tnode);
TNode *getChildById(TNode *p_tnode, unsigned long long id);
TNode *getChildByValue(TNode *p_tnode, int type, void *value);
TNode *getChildById(TNode *p_tnode, const SID *s_id);
TNode *getChildByValue(TNode *p_tnode, unsigned int type, void *value);
TNode *getChildByIndex(TNode *p_tnode, unsigned long long index);
unsigned long long getIndexByChild(TNode *f_tnode, TNode *c_tnode);
int removeChildById(TNode *p_tnode, unsigned long long id);
int removeChildById(TNode *p_tnode, const SID *s_id);
int removeChildByIndex(TNode *p_tnode, unsigned long long index);
int removeChildByValue(TNode *p_tnode, int type, void *value);
int removeChildByValue(TNode *p_tnode, unsigned int type, void *value);
int TreeThroughDown(Tree *p_tree, int(*func)(TNode *, unsigned long long height));
int TreeThroughUp(Tree *p_tree, int(*func)(TNode *, unsigned long long height));
int TreeTravel(Tree *p_tree, int(*func)(TNode *, unsigned long long height));
int _dogetChildById(int type, void *value);
int _dogetChildByValue(int type, void *value);
int _dogetChildById(unsigned int type, void *value);
int _dogetChildByValue(unsigned int type, void *value);
int _doreleaseTree(TNode *p_tnode, unsigned long long height);
int _doTreeThroughDown(TNode *p_tnode, int height, int(*func)(TNode *, unsigned long long height));
int _doTreeThroughUp(TNode *p_tnode, int height, int(*func)(TNode *, unsigned long long height));
@ -64,8 +68,8 @@ static int target_type;
static void *target_value;
static TNode *target_value_value;
static unsigned long long target_id;
static TNode *target_value_id;
static SID *target_sid;
static TNode *target_value_sid;
static List *tree_list;
static List *tnode_list;

View File

@ -17,7 +17,20 @@
#define LIST 5
#define STACK 6
#define TREE 7
#define LIST_NODE 8
#define TREE_NODE 9
#define STACK_NODE 10
#define TYPE_LEN 5
#define DEEPC 1
#define DEEPB 2
#define DEEPA 3
#define DEEPC_LEN 4
#define DEEPB_LEN 8
#define DEEPA_LEN 32
#define DATA_BIT 5
#endif /* type_h */