pub struct LowestCommonAncestor { /* private fields */ }
Expand description
根付き木の LCA です。
§Examples
use lowest_common_ancestor::LowestCommonAncestor;
// 0 -- 2 -- 4
// | |
// 1 3
let lca = LowestCommonAncestor::new(5, 0, &[(0, 1), (0, 2), (2, 3), (2, 4)]);
assert_eq!(lca.get(0, 1), 0);
assert_eq!(lca.get(0, 4), 0);
assert_eq!(lca.get(1, 1), 1);
assert_eq!(lca.get(1, 2), 0);
assert_eq!(lca.get(2, 3), 2);
assert_eq!(lca.get(3, 4), 2);
Implementations§
Auto Trait Implementations§
impl Freeze for LowestCommonAncestor
impl RefUnwindSafe for LowestCommonAncestor
impl Send for LowestCommonAncestor
impl Sync for LowestCommonAncestor
impl Unpin for LowestCommonAncestor
impl UnwindSafe for LowestCommonAncestor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more