pub unsafe fn splay<Spec, Data>(
node: BstNodePtr<<Spec as BstSpec>::Data, <Spec as BstSpec>::Parent>,
) -> BstNodePtr<<Spec as BstSpec>::Data, <Spec as BstSpec>::Parent>where
Spec: BstSpec<Data = Data, Parent = WithParent<Data>>,Expand description
Moves node to the root of its auxiliary tree and returns the previous root.
ยงSafety
node and every pointer reachable through its auxiliary-parent chain must
refer to live nodes of the same tree.
Examples found in repository?
crates/competitive/src/tree/top_tree.rs (line 381)
378 unsafe fn splay_top(node: TopPtr<S, A>) {
379 let root = if A::ROOT_TO_NODE_TOP_DOWN {
380 unsafe {
381 splay_operations::with_parent::splay::<TopBstSpec<S, A>, TopTreeData<S, A>>(node)
382 }
383 } else {
384 unsafe {
385 splay_operations::with_parent::splay_with_local_top_down::<
386 TopBstSpec<S, A>,
387 TopTreeData<S, A>,
388 >(node)
389 }
390 };
391 if root != node {
392 unsafe {
393 (*node.as_ptr()).data.belong = (*root.as_ptr()).data.belong.take();
394 }
395 }
396 }More examples
crates/competitive/src/tree/link_cut_tree.rs (line 216)
213 unsafe fn splay(node: LinkCutPtr<S>) {
214 let root = if S::ROOT_TO_NODE_TOP_DOWN {
215 unsafe {
216 splay_operations::with_parent::splay::<LinkCutBstSpec<S>, LinkCutData<S>>(node)
217 }
218 } else {
219 unsafe {
220 splay_operations::with_parent::splay_with_local_top_down::<
221 LinkCutBstSpec<S>,
222 LinkCutData<S>,
223 >(node)
224 }
225 };
226 if root != node {
227 unsafe {
228 LinkCutBstSpec::<S>::with_two_inner_mut(root, node, S::transfer_path_parent);
229 }
230 }
231 }