@@ -9,7 +9,7 @@ mod tests;
9
9
/// Simple implementation of a union-find data structure, i.e. a disjoint-set
10
10
/// forest.
11
11
#[ derive( Debug ) ]
12
- pub ( crate ) struct UnionFind < Key : Idx > {
12
+ pub struct UnionFind < Key : Idx > {
13
13
table : IndexVec < Key , UnionFindEntry < Key > > ,
14
14
}
15
15
@@ -28,7 +28,7 @@ struct UnionFindEntry<Key> {
28
28
impl < Key : Idx > UnionFind < Key > {
29
29
/// Creates a new disjoint-set forest containing the keys `0..num_keys`.
30
30
/// Initially, every key is part of its own one-element set.
31
- pub ( crate ) fn new ( num_keys : usize ) -> Self {
31
+ pub fn new ( num_keys : usize ) -> Self {
32
32
// Initially, every key is the root of its own set, so its parent is itself.
33
33
Self { table : IndexVec :: from_fn_n ( |key| UnionFindEntry { parent : key, rank : 0 } , num_keys) }
34
34
}
@@ -38,7 +38,7 @@ impl<Key: Idx> UnionFind<Key> {
38
38
///
39
39
/// Also updates internal data structures to make subsequent `find`
40
40
/// operations faster.
41
- pub ( crate ) fn find ( & mut self , key : Key ) -> Key {
41
+ pub fn find ( & mut self , key : Key ) -> Key {
42
42
// Loop until we find a key that is its own parent.
43
43
let mut curr = key;
44
44
while let parent = self . table [ curr] . parent
@@ -60,7 +60,7 @@ impl<Key: Idx> UnionFind<Key> {
60
60
/// Merges the set containing `a` and the set containing `b` into one set.
61
61
///
62
62
/// Returns the common root of both keys, after the merge.
63
- pub ( crate ) fn unify ( & mut self , a : Key , b : Key ) -> Key {
63
+ pub fn unify ( & mut self , a : Key , b : Key ) -> Key {
64
64
let mut a = self . find ( a) ;
65
65
let mut b = self . find ( b) ;
66
66
@@ -90,7 +90,7 @@ impl<Key: Idx> UnionFind<Key> {
90
90
91
91
/// Takes a "snapshot" of the current state of this disjoint-set forest, in
92
92
/// the form of a vector that directly maps each key to its current root.
93
- pub ( crate ) fn snapshot ( & mut self ) -> IndexVec < Key , Key > {
93
+ pub fn snapshot ( & mut self ) -> IndexVec < Key , Key > {
94
94
self . table . indices ( ) . map ( |key| self . find ( key) ) . collect ( )
95
95
}
96
96
}
0 commit comments