コード例 #1
0
/*
Right- Left Rotation
*/
avl_node *avlTree::rl_rotation(avl_node *parent)
{
	avl_node *temp;
	temp = parent->right;
	parent->right = ll_rotation(temp);
	return rr_rotation(parent);
}
コード例 #2
0
/*
Left- Right Rotation
*/
avl_node *avlTree::lr_rotation(avl_node *parent)
{
	avl_node *temp;
	temp = parent->left;
	parent->left = rr_rotation(temp);
	return ll_rotation(parent);
}
コード例 #3
0
ファイル: wdbkeyindex.cpp プロジェクト: Smitt64/WoWSatat
WDBKeyIndex::WDBKeyIndexNode *WDBKeyIndex::rl_rotation(WDBKeyIndexNode *parent)
{
    WDBKeyIndexNode *temp;
    temp = parent->right;
    parent->right = ll_rotation (temp);
    return rr_rotation (parent);
}
コード例 #4
0
ファイル: wdbkeyindex.cpp プロジェクト: Smitt64/WoWSatat
WDBKeyIndex::WDBKeyIndexNode *WDBKeyIndex::lr_rotation(WDBKeyIndexNode *parent)
{
    WDBKeyIndexNode *temp;
    temp = parent->left;
    parent->left = rr_rotation (temp);
    return ll_rotation (parent);
}
コード例 #5
0
/*
Balancing AVL Tree
*/
avl_node *avlTree::balance(avl_node *temp)
{
	int bal_factor = diff(temp);
	if (bal_factor > 1)
	{
		if (diff(temp->left) > 0)
			temp = ll_rotation(temp);
		else
			temp = lr_rotation(temp);
	}
	else if (bal_factor < -1)
	{
		if (diff(temp->right) > 0)
			temp = rl_rotation(temp);
		else
			temp = rr_rotation(temp);
	}
	return temp;
}
コード例 #6
0
ファイル: wdbkeyindex.cpp プロジェクト: Smitt64/WoWSatat
WDBKeyIndex::WDBKeyIndexNode *WDBKeyIndex::balance(WDBKeyIndexNode *temp)
{
    int bal_factor = diff (temp);
    if (bal_factor >1)
    {
        if (diff (temp->left) > 0)
            temp = ll_rotation (temp);
        else
            temp = lr_rotation (temp);
    }
    else if (bal_factor < 1)
    {
        if (diff (temp->right) > 0)
            temp = rl_rotation (temp);
        else
            temp = rr_rotation (temp);
    }
    return temp;
}