Skip to content

Commit 1cb45a5

Browse files
committed
Change Dsu#groups() return type
1 parent 0c1f536 commit 1cb45a5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/scala/io/github/acl4s/Dsu.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,23 @@ case class Dsu(n: Int) {
5656
-parentOrSize(leader(a))
5757
}
5858

59-
def groups(): Seq[Seq[Int]] = {
59+
def groups(): collection.Seq[collection.Seq[Int]] = {
6060
val leader_buf = new Array[Int](n)
6161
val group_size = new Array[Int](n)
6262
(0 until n).foreach(i => {
6363
leader_buf(i) = leader(i)
6464
group_size(leader_buf(i)) += 1
6565
})
6666

67-
val result = new Array[mutable.ArrayBuffer[Int]](n)
67+
val result = new mutable.ArrayBuffer[mutable.Buffer[Int]](n)
6868
(0 until n).foreach(i => {
69-
result(i) = new mutable.ArrayBuffer(group_size(i))
69+
result += new mutable.ArrayBuffer(group_size(i))
7070
})
7171
(0 until n).foreach(i => {
7272
result(leader_buf(i)) += i
7373
})
7474

75-
result.collect {
76-
case buf if buf.nonEmpty => buf.toSeq
77-
}.toSeq
75+
result.filter(_.nonEmpty)
7876
}
7977

8078
}

0 commit comments

Comments
 (0)