MCPcopy Create free account
hub / github.com/douchuan/algorithm / rotate_left

Function rotate_left

src/tree/binary/rb2.rs:305–313  ·  view source on GitHub ↗

h x / \ / \ A R(x) => R(h) C / \ / \ B C A B 旋转操作会改变红链接的指向,所以旋转之后 h 变为 R(h) 旋转操作可以保持rb tree的两个重要性质:有序性(中序)和完美平衡性 */ make a right-leaning link lean to the left

(h: Option<NonNull<Node<K, V>>>)

Source from the content-addressed store, hash-verified

303*/
304/// make a right-leaning link lean to the left
305fn rotate_left<K, V>(h: Option<NonNull<Node<K, V>>>) -> Option<NonNull<Node<K, V>>> {
306 let mut h = NodeQuery::new(h);
307 let mut x = h.right();
308 h.set_right(x.left().node);
309 x.set_left(h.node);
310 x.set_color(h.color().unwrap());
311 h.set_color(Color::Red);
312 x.node
313}
314
315/*
316 h x

Callers 2

balanceFunction · 0.70
move_red_leftFunction · 0.70

Calls 6

set_colorMethod · 0.80
rightMethod · 0.45
set_rightMethod · 0.45
leftMethod · 0.45
set_leftMethod · 0.45
colorMethod · 0.45

Tested by

no test coverage detected