class BTreeNode : public LinkedNode
{
public:
BTreeNode
(BTreeNode* child0, int key0, BTreeNode* child1);
BTreeNode
(const BTreeNode& sibling);
bool isNotLeaf
(void) const;
BTreeNode* findChild
(int newKey) const;
BTreeNode* addKey
(int newKey, BTreeNode* newChild = 0);
BTreeNode* getChild
(int i) const;
void write
(ostream& outfile) const;
private:
void setChild
(int i, BTreeNode* child);
BTreeNode* getParent
(void) const;
void setParent
(BTreeNode* newParent);
private:
int keyCount;
int keys [5]; // 5th used for split
};
ostream& operator << (ostream& outfile, const BTreeNode& node);
BTreeNode::BTreeNode (BTreeNode* child0, int key0, BTreeNode* child1)
{
parent = 0;
keyCount = 1;
keys[0] = key0;
children[0] = child0; // 0 for original root
children[1] = child1; // 0 for original root
for (int i = 1; i <= 3; i++) // is this loop necessary?
{
// key i = +INFINITY;
// child i+1 = 0;
}
for (i = 0; i <= 1; i++)
{
if // (child i != 0) // true for new roots
// child i's parent = this;
}
}
My professor has me confused with this constructor. Is children [] and parent suppose to be part of the keys array or is it private data for BTreeNode that he forgot to include in the .h file??
Thanks for the help.