aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-graph
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-10-24 11:37:55 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-10-24 12:21:22 +0200
commit28f3e15dcd291163c41a1cab1c987344064cf40d (patch)
treec57c7bcdb64beb03bd3b669e674ea8ad73ce99b5 /sonar-graph
parent5e77c6a792172648da384f133df2d88451c85b9e (diff)
downloadsonarqube-28f3e15dcd291163c41a1cab1c987344064cf40d.tar.gz
sonarqube-28f3e15dcd291163c41a1cab1c987344064cf40d.zip
Replace HashSet by LinkedHashSet to ease reproducibility in test cases
Diffstat (limited to 'sonar-graph')
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java b/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java
index 6dfb67b633d..29402fcc978 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java
@@ -21,7 +21,7 @@ package org.sonar.graph;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -30,7 +30,7 @@ public class CycleDetector<V> {
private Set<V> vertices;
private DirectedGraphAccessor<V, ? extends Edge> graph;
private Set<V> analyzedVertices;
- private Set<Cycle> cycles = new HashSet<Cycle>();
+ private Set<Cycle> cycles = new LinkedHashSet<Cycle>();
private Set<Edge> edgesToExclude;
private long searchCyclesCalls = 0;
private int maxSearchDepth = -1;
@@ -38,7 +38,7 @@ public class CycleDetector<V> {
private int maxCyclesToFound = Integer.MAX_VALUE;
public CycleDetector(DirectedGraphAccessor<V, ? extends Edge> graph, Collection<V> vertices) {
- init(graph, vertices, new HashSet<Edge>());
+ init(graph, vertices, new LinkedHashSet<Edge>());
}
public CycleDetector(DirectedGraphAccessor<V, ? extends Edge> graph, Collection<V> vertices, Set<Edge> edgesToExclude) {
@@ -46,7 +46,7 @@ public class CycleDetector<V> {
}
public CycleDetector(DirectedGraphAccessor<V, ? extends Edge> graph) {
- init(graph, graph.getVertices(), new HashSet<Edge>());
+ init(graph, graph.getVertices(), new LinkedHashSet<Edge>());
}
public CycleDetector(DirectedGraphAccessor<V, ? extends Edge> graph, Set<Edge> edgesToExclude) {
@@ -55,8 +55,8 @@ public class CycleDetector<V> {
private void init(DirectedGraphAccessor<V, ? extends Edge> graph, Collection<V> vertices, Set<Edge> edgesToExclude) {
this.graph = graph;
- this.vertices = new HashSet<V>(vertices);
- this.analyzedVertices = new HashSet<V>();
+ this.vertices = new LinkedHashSet<V>(vertices);
+ this.analyzedVertices = new LinkedHashSet<V>();
this.edgesToExclude = edgesToExclude;
}
@@ -87,7 +87,7 @@ public class CycleDetector<V> {
try {
for (V vertex : vertices) {
if (maxSearchDepthActivated || !analyzedVertices.contains(vertex)) {
- Set<V> tmpAnalyzedVertices = new HashSet<V>();
+ Set<V> tmpAnalyzedVertices = new LinkedHashSet<V>();
searchCycles(vertex, new ArrayList<V>(), tmpAnalyzedVertices);
analyzedVertices.addAll(tmpAnalyzedVertices);
}
@@ -104,7 +104,7 @@ public class CycleDetector<V> {
for (Edge<V> edge : graph.getOutgoingEdges(fromVertex)) {
V toVertex = edge.getTo();
if (!edgesToExclude.contains(edge) && vertices.contains(toVertex)
- && (maxSearchDepthActivated || !analyzedVertices.contains(toVertex))) {
+ && (maxSearchDepthActivated || !analyzedVertices.contains(toVertex))) {
if (path.contains(toVertex)) {
path.add(toVertex);
List<V> cyclePath = path.subList(path.indexOf(toVertex), path.size());