(&self)
| 223 | |
| 224 | impl ToString for UF { |
| 225 | fn to_string(&self) -> String { |
| 226 | let mut buf = Vec::new(); |
| 227 | buf.push(format!("{} sets", self.count)); |
| 228 | for i in 0..self.parent.len() { |
| 229 | buf.push(format!( |
| 230 | "{}: parent = {}, rank = {}", |
| 231 | i, self.parent[i], self.rank[i] |
| 232 | )); |
| 233 | } |
| 234 | buf.join("\n") |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | macro_rules! uf_util { |