Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2219)

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/utilities/collection/DirectedGraph.java

Issue 198453002: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | editor/util/plugins/com.google.dart.java2dart/resources/ast_include.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/utilities/collection/DirectedGraph.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/utilities/collection/DirectedGraph.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/utilities/collection/DirectedGraph.java
index 3cf9d4aeb91f27ec0a82a2ab9448a1748e39d0ec..7ef625b4388daadb59daa3f87438dc1f3dd8eb7d 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/utilities/collection/DirectedGraph.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/utilities/collection/DirectedGraph.java
@@ -13,6 +13,8 @@
*/
package com.google.dart.engine.utilities.collection;
+import com.google.dart.engine.utilities.translation.DartBlockBody;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -73,7 +75,12 @@ public class DirectedGraph<N> {
* Instances of the class {@code SccFinder} implement Tarjan's Algorithm for finding the strongly
* connected components in a graph.
*/
- private class SccFinder {
+ private static class SccFinder<N> {
+ /**
+ * The graph to work with.
+ */
+ private DirectedGraph<N> graph;
+
/**
* The index used to uniquely identify the depth of nodes.
*/
@@ -92,8 +99,9 @@ public class DirectedGraph<N> {
/**
* Initialize a newly created finder.
*/
- public SccFinder() {
+ public SccFinder(DirectedGraph<N> graph) {
super();
+ this.graph = graph;
}
// public HashSet<ArrayList<N>> allComponents() {
@@ -160,7 +168,7 @@ public class DirectedGraph<N> {
//
// Consider successors of v
//
- HashSet<N> tails = edges.get(v);
+ HashSet<N> tails = graph.edges.get(v);
if (tails != null) {
for (N w : tails) {
NodeInfo<N> wInfo = nodeMap.get(w);
@@ -261,7 +269,7 @@ public class DirectedGraph<N> {
if (node == null) {
throw new IllegalArgumentException();
}
- SccFinder finder = new SccFinder();
+ SccFinder<N> finder = new SccFinder<N>(this);
return finder.componentContaining(node);
}
@@ -364,6 +372,11 @@ public class DirectedGraph<N> {
*
* @return a sink node
*/
+ @DartBlockBody({//
+ "for (N key in _edges.keys) {",//
+ " if (_edges[key].isEmpty) return key;",//
+ "}",//
+ "return null;"})
private N findSink() {
for (Map.Entry<N, HashSet<N>> entry : edges.entrySet()) {
if (entry.getValue().isEmpty()) {
« no previous file with comments | « no previous file | editor/util/plugins/com.google.dart.java2dart/resources/ast_include.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698