加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cBST.h 2.06 KB
一键复制 编辑 原始数据 按行查看 历史
Corona 提交于 2021-09-08 11:07 . finished delete int function.
/**
* Copyright (c) 2021 Corona.
* cBST is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
#ifndef __CBST_H
#define __CBST_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#define cBST_TRUE ((cBST_BOOL)1)
#define cBST_FALSE ((cBST_BOOL)0)
#define cBST_TYPE_INTEGER (1<<1)
#define cBST_TYPE_DOUBLE (1<<2)
#define cBST_TYPE_STRING (1<<3)
#define cBST_LEFT (2<<1)
#define cBST_RIGHT (2<<2)
typedef int cBST_BOOL;
typedef int cBST_INTEGER;
/**
* cBST对象
*/
typedef struct cBST {
int type;
int valueInt;
double valueDouble;
char* valueString;
cBST_BOOL isEmpty;
struct cBST* father;
struct cBST* leftChild;
struct cBST* rightChild;
} cBST;
/**
* Some Tools.
*/
cBST_BOOL cBST_HasLeftChild( cBST* );
cBST_BOOL cBST_HasRightChild( cBST* );
cBST_INTEGER cBST_Size( cBST* );
cBST_INTEGER cBST_Height( cBST* );
void cBST_Print( FILE*, const unsigned int, cBST* );
void cBST_PrintPretty( FILE*, cBST* );
/**
* Create a New cBST.
*/
cBST* cBST_NewEmptyBST( void );
cBST* cBST_NewIntBST( const int );
cBST* cBST_NewDoubleBST( const double );
cBST* cBST_NewStringBST( const char* );
/**
* Add Int/Double/String from a cBST;
*/
cBST_BOOL cBST_AddInt( cBST**, const int );
cBST_BOOL cBST_AddDouble( cBST**, const double );
cBST_BOOL cBST_AddString( cBST**, const char* );
/**
* Search from a cBST.
*/
cBST_BOOL cBST_SearchInt( cBST*, const int );
cBST_BOOL cBST_SearchDouble( cBST*, const double );
cBST_BOOL cBST_SearchString( cBST*, const char* );
/**
* Delete Int/Double/String value from cBST.
*/
cBST_BOOL cBST_DeleteInt( cBST**, const int );
#ifdef __cplusplus
}
#endif
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化