-
Notifications
You must be signed in to change notification settings - Fork 0
/
InternalNode.cpp
66 lines (47 loc) · 1.55 KB
/
InternalNode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include "InternalNode.h"
using namespace std;
InternalNode::InternalNode(int ISize, int LSize,
InternalNode *p, BTreeNode *left, BTreeNode *right) :
BTreeNode(LSize, p, left, right), internalSize(ISize)
{
keys = new int[internalSize]; // keys[i] is the minimum of children[i]
children = new BTreeNode* [ISize];
} // InternalNode::InternalNode()
void InternalNode::setKeys(BTreeNode *child) {
for(int i = 0; i < count; i++)
keys[i] = children[i]->getMinimum();
if(parent)
parent->setKeys(this);
// parent minimum?
} // InternalNode::setKeys() - sets keys of internal node
int InternalNode::getMinimum()const
{
if(count > 0) // should always be the case
return children[0]->getMinimum();
else
return 0;
} // InternalNode::getMinimum()
InternalNode* InternalNode::insert(int value)
{
// students must write this
return NULL; // to avoid warnings for now.
} // InternalNode::insert()
void InternalNode::insert(BTreeNode *oldRoot, BTreeNode *node2)
{ // Node must be the root, and node1
// students must write this
} // InternalNode::insert()
void InternalNode::insert(BTreeNode *newNode) // from a sibling
{
// students may write this
} // InternalNode::insert()
void InternalNode::print(Queue <BTreeNode*> &queue)
{
int i;
cout << "Internal: ";
for (i = 0; i < count; i++)
cout << keys[i] << ' ';
cout << endl;
for(i = 0; i < count; i++)
queue.enqueue(children[i]);
} // InternalNode::print()