mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Crash if a cycle is detected.
This commit is contained in:
parent
e992d8b935
commit
db69b4cc2a
1 changed files with 4 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.beust.kobalt.misc
|
||||
|
||||
import com.beust.kobalt.KobaltException
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import com.google.common.collect.HashMultimap
|
||||
import java.util.*
|
||||
|
@ -29,6 +30,9 @@ class Topological<T> {
|
|||
val freeNodes = all.filter {
|
||||
dependMap.get(it).isEmpty()
|
||||
}
|
||||
if (freeNodes.isEmpty()) {
|
||||
throw KobaltException("The dependency graph has a cycle: $all")
|
||||
}
|
||||
result.addAll(freeNodes)
|
||||
all.removeAll(freeNodes)
|
||||
val newMap = HashMultimap.create<T, T>()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue