GreatSyntacticShift: Parser test data fixed
This commit is contained in:
@@ -24,11 +24,11 @@ class Graph<V, E> {
|
||||
|
||||
fun neighbours(v : Vertex<V>) = edges.filter{it.from == v}.map{it.to} // type is IIterable<Vertex<V>>
|
||||
|
||||
fun dfs(handler : fun (V) : Unit) {
|
||||
fun dfs(handler : (V) -> Unit) {
|
||||
val visited = HashSet<Vertex<V>>()
|
||||
vertices.foreach{dfs(it, visited, handler)}
|
||||
|
||||
fun dfs(current : Vertex<V>, visited : ISet<Vertex<V>>, handler : fun (V) : Unit) {
|
||||
fun dfs(current : Vertex<V>, visited : ISet<Vertex<V>>, handler : (V) -> Unit) {
|
||||
if (!visited.add(current))
|
||||
return
|
||||
handler(current)
|
||||
@@ -36,7 +36,7 @@ class Graph<V, E> {
|
||||
}
|
||||
}
|
||||
|
||||
public fun traverse(pending : IPushPop<Vertex<V>>, visited : ISet<Vertex<V>>, handler : fun (V) : Unit) {
|
||||
public fun traverse(pending : IPushPop<Vertex<V>>, visited : ISet<Vertex<V>>, handler : (V) -> Unit) {
|
||||
vertices.foreach {
|
||||
if (!visited.add(it))
|
||||
continue
|
||||
@@ -44,7 +44,7 @@ class Graph<V, E> {
|
||||
while (!pending.isEmpty) {
|
||||
val current = pending.pop()
|
||||
handler(current);
|
||||
neighbours(current).foreach { n =>
|
||||
neighbours(current).foreach { n ->
|
||||
if (visited.add(n)) {
|
||||
pending.push(n)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user