InfinityUtils/RedBlackTree.h
void fixDelete(Node* x) {
		Node* s;
		while (x != root && x->color == 0) {
			if (x == x->parent->left) {
				s = x->parent->right;
				if (s->color == 1) {
					// case 3.1
					s->color = 0;
					x->parent->color = 1;
					leftRotate(x->parent);
					s = x->parent->right;
				}

				if (s->left->color == 0 && s->right->color == 0) {
					// case 3.2
					s->color = 1;
					x = x->parent;
				} else {
					if (s->right->color == 0) {
						// case 3.3
						s->left->color = 0;
						s->color = 1;
						rightRotate(s);
						s = x->parent->right;
					}

					// case 3.4
					s->color = x->parent->color;
					x->parent->color = 0;
					s->right->color = 0;
					leftRotate(x->parent);
					x = root;
				}
			} else {
				s = x->parent->left;
				if (s->color == 1) {
					// case 3.1
					s->color = 0;
					x->parent->color = 1;
					rightRotate(x->parent);
					s = x->parent->left;
				}

				#pragma warning(push)
				#pragma warning(disable: 6287)
				if (s->right->color == 0 && s->right->color == 0) {
					// case 3.2
					s->color = 1;
					x = x->parent;
				} else {
					if (s->left->color == 0) {
						// case 3.3
						s->right->color = 0;
						s->color = 1;
						leftRotate(s);
						s = x->parent->left;
					}

					// case 3.4
					s->color = x->parent->color;
					x->parent->color = 0;
					s->left->color = 0;
					rightRotate(x->parent);
					x = root;
				}
				#pragma warning(pop)
			}
		}
		x->color = 0;
	}
// fix the rb tree modified by the delete operation

fix the rb tree modified by the delete operation
fix the rb tree modified by the delete operation
void fixDelete(Node* x) {
		Node* s;
		while (x != root && x->color == 0) {
			if (x == x->parent->left) {
				s = x->parent->right;
				if (s->color == 1) {
					s->color = 0;
					x->parent->color = 1;
					leftRotate(x->parent);
					s = x->parent->right;
				}
				if (s->left->color == 0 && s->right->color == 0) {
					s->color = 1;
					x = x->parent;
				} else {
					if (s->right->color == 0) {
						s->left->color = 0;
						s->color = 1;
						rightRotate(s);
						s = x->parent->right;
					}
					s->color = x->parent->color;
					x->parent->color = 0;
					s->right->color = 0;
					leftRotate(x->parent);
					x = root;
				}
			} else {
				s = x->parent->left;
				if (s->color == 1) {
					s->color = 0;
					x->parent->color = 1;
					rightRotate(x->parent);
					s = x->parent->left;
				}
				#pragma warning(push)
				#pragma warning(disable: 6287)
				if (s->right->color == 0 && s->right->color == 0) {
					s->color = 1;
					x = x->parent;
				} else {
					if (s->left->color == 0) {
						s->right->color = 0;
						s->color = 1;
						leftRotate(s);
						s = x->parent->left;
					}
					s->color = x->parent->color;
					x->parent->color = 0;
					s->left->color = 0;
					rightRotate(x->parent);
					x = root;
				}
				#pragma warning(pop)
			}
		}
		x->color = 0;
	}
void fixDelete ( Node * x ) { Node * s ; while ( x != root && x -> color == 0 ) { if ( x == x -> parent -> left ) { s = x -> parent -> right ; if ( s -> color == 1 ) { s -> color = 0 ; x -> parent -> color = 1 ; leftRotate ( x -> parent ) ; s = x -> parent -> right ; } if ( s -> left -> color == 0 && s -> right -> color == 0 ) { s -> color = 1 ; x = x -> parent ; } else { if ( s -> right -> color == 0 ) { s -> left -> color = 0 ; s -> color = 1 ; rightRotate ( s ) ; s = x -> parent -> right ; } s -> color = x -> parent -> color ; x -> parent -> color = 0 ; s -> right -> color = 0 ; leftRotate ( x -> parent ) ; x = root ; } } else { s = x -> parent -> left ; if ( s -> color == 1 ) { s -> color = 0 ; x -> parent -> color = 1 ; rightRotate ( x -> parent ) ; s = x -> parent -> left ; } #pragma  warning(push)
 #pragma  warning(disable: 6287)
 if ( s -> right -> color == 0 && s -> right -> color == 0 ) { s -> color = 1 ; x = x -> parent ; } else { if ( s -> left -> color == 0 ) { s -> right -> color = 0 ; s -> color = 1 ; leftRotate ( s ) ; s = x -> parent -> left ; } s -> color = x -> parent -> color ; x -> parent -> color = 0 ; s -> left -> color = 0 ; rightRotate ( x -> parent ) ; x = root ; } #pragma  warning(pop)
 } } x -> color = 0 ; }
fix the rb tree modified by the delete operation
fix the rb tree modified by the delete operation
// case 3.1
 // case 3.2
 // case 3.3
 // case 3.4
 // case 3.1
 // case 3.2
 // case 3.3
 // case 3.4
