| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.utilities.collection; | 8 library engine.utilities.collection; |
| 9 | 9 |
| 10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 | 330 |
| 331 /** | 331 /** |
| 332 * Instances of the class `SccFinder` implement Tarjan's Algorithm for finding t
he strongly | 332 * Instances of the class `SccFinder` implement Tarjan's Algorithm for finding t
he strongly |
| 333 * connected components in a graph. | 333 * connected components in a graph. |
| 334 */ | 334 */ |
| 335 class DirectedGraph_SccFinder<N> { | 335 class DirectedGraph_SccFinder<N> { |
| 336 /** | 336 /** |
| 337 * The graph to work with. | 337 * The graph to work with. |
| 338 */ | 338 */ |
| 339 DirectedGraph<N> _graph; | 339 final DirectedGraph<N> _graph; |
| 340 | 340 |
| 341 /** | 341 /** |
| 342 * The index used to uniquely identify the depth of nodes. | 342 * The index used to uniquely identify the depth of nodes. |
| 343 */ | 343 */ |
| 344 int _index = 0; | 344 int _index = 0; |
| 345 | 345 |
| 346 /** | 346 /** |
| 347 * The stack of nodes that are being visited in order to identify components. | 347 * The stack of nodes that are being visited in order to identify components. |
| 348 */ | 348 */ |
| 349 List<N> _stack = new List<N>(); | 349 List<N> _stack = new List<N>(); |
| 350 | 350 |
| 351 /** | 351 /** |
| 352 * A table mapping nodes to information about the nodes that is used by this a
lgorithm. | 352 * A table mapping nodes to information about the nodes that is used by this a
lgorithm. |
| 353 */ | 353 */ |
| 354 Map<N, DirectedGraph_NodeInfo<N>> _nodeMap = new Map<N, DirectedGraph_NodeInfo
<N>>(); | 354 Map<N, DirectedGraph_NodeInfo<N>> _nodeMap = new Map<N, DirectedGraph_NodeInfo
<N>>(); |
| 355 | 355 |
| 356 /** | 356 /** |
| 357 * Initialize a newly created finder. | 357 * Initialize a newly created finder. |
| 358 */ | 358 */ |
| 359 DirectedGraph_SccFinder(DirectedGraph<N> graph) : super() { | 359 DirectedGraph_SccFinder(this._graph) : super(); |
| 360 this._graph = graph; | |
| 361 } | |
| 362 | 360 |
| 363 /** | 361 /** |
| 364 * Return a list containing the nodes that are part of the strongly connected
component that | 362 * Return a list containing the nodes that are part of the strongly connected
component that |
| 365 * contains the given node. | 363 * contains the given node. |
| 366 * | 364 * |
| 367 * @param node the node used to identify the strongly connected component to b
e returned | 365 * @param node the node used to identify the strongly connected component to b
e returned |
| 368 * @return the nodes that are part of the strongly connected component that co
ntains the given | 366 * @return the nodes that are part of the strongly connected component that co
ntains the given |
| 369 * node | 367 * node |
| 370 */ | 368 */ |
| 371 List<N> componentContaining(N node) => _strongConnect(node).component; | 369 List<N> componentContaining(N node) => _strongConnect(node).component; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 // | 423 // |
| 426 // If v is a root node, pop the stack and generate an SCC | 424 // If v is a root node, pop the stack and generate an SCC |
| 427 // | 425 // |
| 428 if (vInfo.lowlink == vInfo.index) { | 426 if (vInfo.lowlink == vInfo.index) { |
| 429 List<N> component = new List<N>(); | 427 List<N> component = new List<N>(); |
| 430 N w; | 428 N w; |
| 431 do { | 429 do { |
| 432 w = _pop(); | 430 w = _pop(); |
| 433 component.add(w); | 431 component.add(w); |
| 434 _nodeMap[w].component = component; | 432 _nodeMap[w].component = component; |
| 435 } while (w != v); | 433 } while (!identical(w, v)); |
| 436 } | 434 } |
| 437 return vInfo; | 435 return vInfo; |
| 438 } | 436 } |
| 439 } | 437 } |
| 440 | 438 |
| 441 /** | 439 /** |
| 442 * The class `ListUtilities` defines utility methods useful for working with [Li
st | 440 * The class `ListUtilities` defines utility methods useful for working with [Li
st |
| 443 ]. | 441 ]. |
| 444 */ | 442 */ |
| 445 class ListUtilities { | 443 class ListUtilities { |
| 446 /** | 444 /** |
| 447 * Add all of the elements in the given array to the given list. | 445 * Add all of the elements in the given array to the given list. |
| 448 * | 446 * |
| 449 * @param list the list to which the elements are to be added | 447 * @param list the list to which the elements are to be added |
| 450 * @param elements the elements to be added to the list | 448 * @param elements the elements to be added to the list |
| 451 */ | 449 */ |
| 452 static void addAll(List list, List<Object> elements) { | 450 static void addAll(List list, List<Object> elements) { |
| 453 int count = elements.length; | 451 int count = elements.length; |
| 454 for (int i = 0; i < count; i++) { | 452 for (int i = 0; i < count; i++) { |
| 455 list.add(elements[i]); | 453 list.add(elements[i]); |
| 456 } | 454 } |
| 457 } | 455 } |
| 458 } | 456 } |
| OLD | NEW |