diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-10-29 11:07:27 -0700 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-10-29 11:07:27 -0700 |
commit | e457333ca386fccf3a79c6d69b0eb86d96d47281 (patch) | |
tree | d2449c4b8b7999e99c430ed98675b2d41dbb4a9e /src | |
parent | d3ac2ca2c3a581152323d315d3765a18c2fb02c0 (diff) | |
download | mill-e457333ca386fccf3a79c6d69b0eb86d96d47281.tar.gz mill-e457333ca386fccf3a79c6d69b0eb86d96d47281.tar.bz2 mill-e457333ca386fccf3a79c6d69b0eb86d96d47281.zip |
Graph tests pass again
Diffstat (limited to 'src')
-rw-r--r-- | src/main/scala/forge/Evaluator.scala | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/main/scala/forge/Evaluator.scala b/src/main/scala/forge/Evaluator.scala index d19b8aa3..85bd5ac6 100644 --- a/src/main/scala/forge/Evaluator.scala +++ b/src/main/scala/forge/Evaluator.scala @@ -159,16 +159,28 @@ object Evaluator{ } } } + + val targetOrdering = topoSortedTargets.values.items.zipWithIndex.toMap val output = new MutableMultiBiMap[Int, Target[_]] - for(target <- topoSortedTargets.values.items){ - for(targetGroup <- grouping.lookupValueOpt(target)){ - val shifted = grouping.removeAll(targetGroup) - output.addAll(output.keys().length, shifted.reverse) - } + + // Sort groups amongst themselves, and sort the contents of each group + // before aggregating it into the final output + for(g <- grouping.values().toArray.sortBy(g => targetOrdering(g.items(0)))){ + output.addAll(output.keys.length, g.toArray.sortBy(targetOrdering)) } output } + def checkTopological(targets: OSet[Target[_]]) = { + val seen = mutable.Set.empty[Target[_]] + for(t <- targets.items.reverseIterator){ + seen.add(t) + for(upstream <- t.inputs){ + assert(!seen(upstream)) + } + } + } + /** * Takes the given targets, finds all the targets they transitively depend * on, and sort them topologically. Fails if there are dependency cycles |