📄 mynode.h
字号:
// MyNode.h
#pragma once
#include "parameters.h"
// MyNode 命令目标
class MyNode : public CObject
{
public:
static int N;
static int M;
int m_n;
int m_level;
// long* k; // N
// void** p; // N+1
long k[MAXIMUM_NUMBER_OF_NODE];
void* p[MAXIMUM_NUMBER_OF_NODE+1];
public:
// 0 correct, -1 wrong input n.
static int SetMaxNumber(int n);
MyNode();
virtual ~MyNode();
bool Create();
bool Release();
bool CreateRoot(long key,MyNode* node1,MyNode* node2);
// Search fuction, Node / Leaf 's search.
// return the position of the key(0 - N)
virtual int Search(long key);
// Insert fuction,
virtual int Insert(long key,void* pkey,int i);
virtual int SplitNode(MyNode* newNode,int m/*type*/); // only use when level = 1
// Delete fuction
virtual int Delete(int i);
virtual long GetMinKey(int i=0);
virtual long GetKeyFromLeft(MyNode* left);
virtual long GetKeyFromRight(MyNode* right);
virtual long UniteRight(MyNode* right);
};
// MyBranch 命令目标
class MyBranch : public MyNode
{
public:
MyBranch();
MyBranch(int level);
virtual ~MyBranch();
// Search fuction, Node / Leaf 's search.
virtual int Search(long key); // return the position of the key(0 - N), -1 is error or no key
// Insert fuction,
virtual int Insert(long key,void* pkey,int i); // return position of noed (0 - N), -1 is error.
// you should new the Leaf or Node in the BPlusTree class.
virtual int SplitNode(MyNode* newNode,int m/*type*/); // only use when level = 1
// Delete fuction
virtual int Delete(int i);
virtual long GetKeyFromLeft(MyNode* left);
virtual long GetKeyFromRight(MyNode* right);
virtual long UniteRight(MyNode* right);
};
// MyLeaf 命令目标
class MyLeaf : public MyNode
{
public:
MyLeaf* m_next;
public:
MyLeaf();
virtual ~MyLeaf();
// Search fuction, Node / Leaf 's search.
virtual int Search(long key); // return the position of the key(0 - N), -1 is error or no key
// Insert fuction,
virtual int Insert(long key,void* pkey,int i); // return position of noed (0 - N), -1 is error.
// you should new the Leaf or Node in the BPlusTree class. return num of key to be moved
virtual int SplitNode(MyNode* newNode,int m/*type*/); // only use when level = 1
// Delete fuction
virtual int Delete(int i);
virtual long GetKeyFromLeft(MyNode* left);
virtual long GetKeyFromRight(MyNode* right);
virtual long UniteRight(MyNode* right);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -