Пример #1
0
void LeafNode::mergeNode(FatherNode* parentNode, FatherNode* childNode, int keyIndex) {
	for (int i = 0; i < childNode->getKeyNum(); ++i) {
		insert(childNode->getKeyValue(i), ((LeafNode*)childNode)->getData(i));
	}
	setRightSibling(((LeafNode*)childNode)->getRightSibling());
	parentNode->removeKey(keyIndex, keyIndex + 1);
}
Пример #2
0
void CLeafNode::mergeChild(CNode* parentNode, CNode* childNode, int keyIndex)
{
    // 合并数据
    for (int i=0; i<childNode->getKeyNum(); ++i)
    {
        insert(childNode->getKeyValue(i), ((CLeafNode*)childNode)->getData(i));
    }
    setRightSibling(((CLeafNode*)childNode)->getRightSibling());
    //父节点删除index的key,
    parentNode->removeKey(keyIndex, keyIndex+1);
}
Пример #3
0
void LeafNode::splitNode(FatherNode* parentNode, int childIndex) {
	LeafNode* newNode = new LeafNode();
	setKeyNum(MIN_LEAF);
	newNode->setKeyNum(MIN_LEAF + 1);
	newNode->setRightSibling(getRightSibling());
	setRightSibling(newNode);
	newNode->setLeftSibling(this);
	int i;
	for (i = 0; i < MIN_LEAF + 1; ++i) {
		newNode->setKeyValue(i, m_KeyValues[i + MIN_LEAF]);
	}
	for (i = 0; i < MIN_LEAF + 1; ++i) {
		newNode->setData(i, m_Datas[i + MIN_LEAF]);
	}
	((InternalNode*)parentNode)->insert(childIndex, childIndex + 1, m_KeyValues[MIN_LEAF], newNode);
}
Пример #4
0
void CLeafNode::split(CNode* parentNode, int childIndex)
{
    CLeafNode* newNode = new CLeafNode();//分裂后的右节点
    setKeyNum(MINNUM_LEAF);
    newNode->setKeyNum(MINNUM_LEAF+1);
    newNode->setRightSibling(getRightSibling());
    setRightSibling(newNode);
    newNode->setLeftSibling(this);
    int i;
    for (i=0; i<MINNUM_LEAF+1; ++i)// 拷贝关键字的值
    {
        newNode->setKeyValue(i, m_KeyValues[i+MINNUM_LEAF]);
    }
    for (i=0; i<MINNUM_LEAF+1; ++i)// 拷贝数据
    {
        newNode->setData(i, m_Datas[i+MINNUM_LEAF]);
    }
    ((CInternalNode*)parentNode)->insert(childIndex, childIndex+1, m_KeyValues[MINNUM_LEAF], newNode);
}
Пример #5
0
/*叶子节点*/
LeafNode::LeafNode() :FatherNode() {
	setType(LEAF);
	setLeftSibling(NULL);
	setRightSibling(NULL);
}
Пример #6
0
// CLeafNode
CLeafNode::CLeafNode():CNode() {
    setType(LEAF);
    setLeftSibling(NULL);
    setRightSibling(NULL);
}