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

Function rotate_right

src/tree/binary/rb2.rs:324–332  ·  view source on GitHub ↗

h x / \ / \ R(x) C => A R(h) / \ / \ A B B C */ make a left-leaning link lean to the right

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

Source from the content-addressed store, hash-verified

322*/
323/// make a left-leaning link lean to the right
324fn rotate_right<K, V>(h: Option<NonNull<Node<K, V>>>) -> Option<NonNull<Node<K, V>>> {
325 let mut h = NodeQuery::new(h);
326 let mut x = h.left();
327 h.set_left(x.right().node);
328 x.set_right(h.node);
329 x.set_color(h.color().unwrap());
330 h.set_color(Color::Red);
331 x.node
332}
333
334/// flip the colors of a node and its two children
335fn flip_colors<K, V>(h: Option<NonNull<Node<K, V>>>) {

Callers 5

del_maxFunction · 0.70
deleteFunction · 0.70
balanceFunction · 0.70
move_red_leftFunction · 0.70
move_red_rightFunction · 0.70

Calls 6

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

Tested by

no test coverage detected