11/*
2- * Copyright (c) 1999, 2021 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1999, 2022 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@ public interface DependencyKind { }
4646 */
4747 public interface Node <D , N extends Node <D , N >> {
4848 /**
49- * visitor method.
49+ * Visitor method.
5050 */
5151 <A > void accept (NodeVisitor <D , N , A > visitor , A arg );
5252 }
@@ -105,7 +105,7 @@ public AbstractNode(D data) {
105105 public abstract DependencyKind [] getSupportedDependencyKinds ();
106106
107107 /**
108- * Get all dependencies of a given kind
108+ * Get all dependencies of a given kind.
109109 */
110110 public abstract Collection <? extends N > getDependenciesByKind (DependencyKind dk );
111111
@@ -126,7 +126,7 @@ public <A> void accept(NodeVisitor<D, N, A> visitor, A arg) {
126126 }
127127
128128 /**
129- * This class specialized Node, by adding elements that are required in order
129+ * This class specializes Node, by adding elements that are required in order
130130 * to perform Tarjan computation of strongly connected components.
131131 */
132132 public abstract static class TarjanNode <D , N extends TarjanNode <D , N >> extends AbstractNode <D , N >
@@ -141,13 +141,14 @@ public TarjanNode(D data) {
141141
142142 public abstract Iterable <? extends N > getAllDependencies ();
143143
144+ @ Override
144145 public int compareTo (N o ) {
145- return ( index < o . index ) ? - 1 : (index == o .index ) ? 0 : 1 ;
146+ return Integer . compare (index , o .index );
146147 }
147148 }
148149
149150 /**
150- * Tarjan's algorithm to determine strongly connected components of a
151+ * Tarjan's algorithm to determine strongly connected components (SCCs) of a
151152 * directed graph in linear time. Works on TarjanNode.
152153 */
153154 public static <D , N extends TarjanNode <D , N >> List <? extends List <? extends N >> tarjan (Iterable <? extends N > nodes ) {
@@ -160,10 +161,10 @@ private static class Tarjan<D, N extends TarjanNode<D, N>> {
160161 /** Unique node identifier. */
161162 int index = 0 ;
162163
163- /** List of SCCs found fso far. */
164+ /** List of SCCs found so far. */
164165 ListBuffer <List <N >> sccs = new ListBuffer <>();
165166
166- /** Stack of all reacheable nodes from given root. */
167+ /** Stack of all reachable nodes from given root. */
167168 ListBuffer <N > stack = new ListBuffer <>();
168169
169170 private List <? extends List <? extends N >> findSCC (Iterable <? extends N > nodes ) {
0 commit comments