MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / rightRotate

Method rightRotate

structure/tree/rbtree.go:237–255  ·  view source on GitHub ↗
(x *RBNode[T])

Source from the content-addressed store, hash-verified

235}
236
237func (t *RB[T]) rightRotate(x *RBNode[T]) {
238 y := x.left
239 x.left = y.right
240 if y.right != t._NIL {
241 y.right.parent = x
242 }
243
244 y.parent = x.parent
245 if x.parent == t._NIL {
246 t.Root = y
247 } else if x == y.parent.right {
248 y.parent.right = y
249 } else {
250 y.parent.left = y
251 }
252
253 y.right = x
254 x.parent = y
255}
256
257func (t *RB[T]) pushFix(k *RBNode[T]) {
258 for k.parent.color == Red {

Callers 2

pushFixMethod · 0.95
deleteFixMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected