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

Method leftRotate

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

Source from the content-addressed store, hash-verified

214}
215
216func (t *RB[T]) leftRotate(x *RBNode[T]) {
217 y := x.right
218 x.right = y.left
219
220 if y.left != t._NIL {
221 y.left.parent = x
222 }
223
224 y.parent = x.parent
225 if x.parent == t._NIL {
226 t.Root = y
227 } else if x == x.parent.left {
228 x.parent.left = y
229 } else {
230 x.parent.right = y
231 }
232
233 y.left = x
234 x.parent = y
235}
236
237func (t *RB[T]) rightRotate(x *RBNode[T]) {
238 y := x.left

Callers 2

pushFixMethod · 0.95
deleteFixMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected