Skip to content

Commit b2fc03d

Browse files
committed
Refactor
1 parent 4ae134e commit b2fc03d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/problem_1970_last_day_where_you_can_still_cross/union_find.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ use std::{mem, ptr};
88
type State = (Cell<u16>, Cell<u16>);
99

1010
impl Solution {
11-
fn get_node(array: &[State], value: &State) -> u16 {
12-
((ptr::from_ref(value) as usize - array.as_ptr() as usize) / mem::size_of::<State>()) as _
11+
fn get_node(union_find: &[State], state: &State) -> u16 {
12+
((ptr::from_ref(state) as usize - union_find.as_ptr() as usize) / mem::size_of::<State>()) as _
1313
}
1414

15-
fn find_root<'a>(union_find: &'a [State], node_state: &'a State) -> &'a State {
16-
let parent = node_state.0.get();
15+
fn find_root<'a>(union_find: &'a [State], state: &'a State) -> &'a State {
16+
let parent = state.0.get();
1717

18-
union_find.get(usize::from(parent)).map_or(node_state, |parent_state| {
18+
union_find.get(usize::from(parent)).map_or(state, |parent_state| {
1919
let root = Self::find_root(union_find, parent_state);
2020

21-
node_state.0.set(Self::get_node(union_find, root));
21+
state.0.set(Self::get_node(union_find, root));
2222

2323
root
2424
})

0 commit comments

Comments
 (0)