bsttreenode.h
来自「此代码运行于visual c++ 6.0的环境下」· C头文件 代码 · 共 64 行
H
64 行
// BstTreeNode.h: interface for the BstTreeNode class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BSTTREENODE_H__DA26FD98_7E19_4395_865C_F1C6DFEDDB76__INCLUDED_)
#define AFX_BSTTREENODE_H__DA26FD98_7E19_4395_865C_F1C6DFEDDB76__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Data.h"
#include "Deque.h"
#include <deque>
#include <algorithm>
using std::deque;
using std::find;
//BST树结点类
class CBstTreeNode{
public:
string Key; //关键码(关键词)
CDeque<CData> Index; //相关文件的信息
CBstTreeNode* left; //左子女指针
CBstTreeNode* right; //右子女指针
CBstTreeNode():Index(){ //构造函数
left = NULL;
right = NULL;
}
CBstTreeNode(string k,CBstTreeNode* l=NULL,CBstTreeNode* r=NULL):left(l),right(r){
Key = k;
} //构造函数
CBstTreeNode(const CBstTreeNode & node ):Index(){
Key = node.Key;
Index = node.Index;
left = NULL;
right = NULL;
} //拷贝构造函数
bool IsExist( const CData & data ){
for( int i = 0; i < Index.size(); i++ ){
if( Index.at(i) == data )
return true;
}
return false;
} //判断包含此信息的对象是否已经存在
CBstTreeNode& operator=(const CBstTreeNode& src){
Key = src.Key;left=NULL;right=NULL;} //重载等号运算符
void insert(const CData& data){
if( !IsExist(data) )
Index.push_back(data);
} //插入一个不存在的新记录
~CBstTreeNode(){
if( left != NULL)
delete left;
if( right != NULL)
delete right;
} //析构函数
};
#endif // !defined(AFX_BSTTREENODE_H__DA26FD98_7E19_4395_865C_F1C6DFEDDB76__INCLUDED_)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?