[ create a new paste ] login | about

Link: http://codepad.org/s10syEet    [ raw code | fork ]

scwizard - C++, pasted on Mar 7:
// "Left" rotation.
if(x->right != nullptr) {
	x->right->prev->left = x->right;
	x->right->prev->left->parent = x->right->prev;

	x->right->prev->right = x->right->left;
	if(x->right->prev->right != nullptr)
		x->right->prev->right->parent = x->right->prev;

	if(x->right != nullptr) {	
		x->right = x->right-right;
		if(x->right != nullptr)
			x->right->parent = x;
	}
}

// "Right" rotation:
if(x->left->left != nullptr) {
	if(x->left->right != nullptr) {
		x->left->right->prev->left = x->left->right;
		x->left->right->prev->left->parent = x->left->right->prev;

		x->left->right->prev->right = x->right;
		x->left->right->prev->right->parent = x->left->right->prev;
	}

	x->right = x->left->left;
	x->right->parent = x;


	x->left->right = nullptr;
	x->left->left = nullptr;
}


Create a new paste based on this one


Comments: