⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node.h

📁 B+树的演示程序
💻 H
字号:
// Node.h

#pragma once

class Node
{
public:		
	static int N;
	static int M;
	int my_num;
	int my_level;
	long* k;		// key N
	Node** p;		// point N+1

public:
	Node(int level=2);
	// a new root that with k[0] = key,p[0] = node1,p[2] = node2
	Node(int key,Node* node1,Node* node2,int level=2);
	~Node();

	static void SetMaxNum(int n=3);

	int Search(long key);

	int Insert(long key,Node* pkey,int i);
	void SplitNode(Node* newNode,int m/*type*/);	// only use when level = 1

	int Delete(int i);
	long GetMinKey(int i=0);
	long GetKeyFromLeft(Node* leftNode);
	long GetKeyFromRight(Node* rightNode);
	long UniteRight(Node* rightNode);
};

class Leaf : public Node
{
public:
	//long** p;		// point N
	Leaf* my_next;	// + 1

public:
	Leaf();
	~Leaf();

	int Search(long key);
	int Find(long key);

	// if return -1 then there isn't key in B+ tree	
	int Insert(long key,long* pkey,int i);	//void* should be long*
    void SplitLeaf(Leaf* newLeaf,int m/*type*/);	// m=0,insert key to the new leaf; m=1, insert key to the leaf.

	int Delete(int i);
	long GetKeyFromLeft(Leaf* leftLeaf);
	long GetKeyFromRight(Leaf* rightLeaf);
	long UniteRight(Leaf* rightLeaf);

	Leaf* Next();
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -