@@ -9,7 +9,7 @@ mod tests;
99/// Simple implementation of a union-find data structure, i.e. a disjoint-set
1010/// forest.
1111#[ derive( Debug ) ]
12- pub ( crate ) struct UnionFind < Key : Idx > {
12+ pub struct UnionFind < Key : Idx > {
1313 table : IndexVec < Key , UnionFindEntry < Key > > ,
1414}
1515
@@ -28,7 +28,7 @@ struct UnionFindEntry<Key> {
2828impl < Key : Idx > UnionFind < Key > {
2929 /// Creates a new disjoint-set forest containing the keys `0..num_keys`.
3030 /// 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 {
3232 // Initially, every key is the root of its own set, so its parent is itself.
3333 Self { table : IndexVec :: from_fn_n ( |key| UnionFindEntry { parent : key, rank : 0 } , num_keys) }
3434 }
@@ -38,7 +38,7 @@ impl<Key: Idx> UnionFind<Key> {
3838 ///
3939 /// Also updates internal data structures to make subsequent `find`
4040 /// operations faster.
41- pub ( crate ) fn find ( & mut self , key : Key ) -> Key {
41+ pub fn find ( & mut self , key : Key ) -> Key {
4242 // Loop until we find a key that is its own parent.
4343 let mut curr = key;
4444 while let parent = self . table [ curr] . parent
@@ -60,7 +60,7 @@ impl<Key: Idx> UnionFind<Key> {
6060 /// Merges the set containing `a` and the set containing `b` into one set.
6161 ///
6262 /// 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 {
6464 let mut a = self . find ( a) ;
6565 let mut b = self . find ( b) ;
6666
@@ -90,7 +90,7 @@ impl<Key: Idx> UnionFind<Key> {
9090
9191 /// Takes a "snapshot" of the current state of this disjoint-set forest, in
9292 /// 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 > {
9494 self . table . indices ( ) . map ( |key| self . find ( key) ) . collect ( )
9595 }
9696}
0 commit comments