Author: simonetripodi Date: Fri Mar 2 08:45:06 2012 New Revision: 1296087 URL: http://svn.apache.org/viewvc?rev=1296087&view=rev Log: [SANDBOX-400] Switch the Base graph implementation underlying data structures to the thread safe version
Modified: commons/sandbox/graph/trunk/src/changes/changes.xml commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java Modified: commons/sandbox/graph/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/changes/changes.xml?rev=1296087&r1=1296086&r2=1296087&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/changes/changes.xml (original) +++ commons/sandbox/graph/trunk/src/changes/changes.xml Fri Mar 2 08:45:06 2012 @@ -23,6 +23,9 @@ </properties> <body> <release version="0.1" date="201?-??-??" description="First release."> + <action dev="simonetripodi" type="fix" issue="SANDBOX-400"> + Switch the Base graph implementation underlying data structures to the thread safe version + </action> <action dev="marcosperanza" type="fix" issue="SANDBOX-354"> Provide a Tarjan's algorithm implementation </action> Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java?rev=1296087&r1=1296086&r2=1296087&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java Fri Mar 2 08:45:06 2012 @@ -20,13 +20,13 @@ package org.apache.commons.graph.model; */ import static java.lang.String.format; +import static java.util.Collections.newSetFromMap; import static java.util.Collections.unmodifiableCollection; import static java.util.Collections.unmodifiableSet; -import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.graph.Edge; import org.apache.commons.graph.Graph; @@ -47,13 +47,13 @@ public abstract class BaseGraph<V extend private static final long serialVersionUID = -8066786787634472712L; - private final Map<V, Set<V>> adjacencyList = new HashMap<V, Set<V>>(); + private final Map<V, Set<V>> adjacencyList = new ConcurrentHashMap<V, Set<V>>(); - private final Set<E> allEdges = new HashSet<E>(); + private final Set<E> allEdges = newSetFromMap( new ConcurrentHashMap<E, Boolean>() ); - private final Map<VertexPair<V>, E> indexedEdges = new HashMap<VertexPair<V>, E>(); + private final Map<VertexPair<V>, E> indexedEdges = new ConcurrentHashMap<VertexPair<V>, E>(); - private final Map<E, VertexPair<V>> indexedVertices = new HashMap<E, VertexPair<V>>(); + private final Map<E, VertexPair<V>> indexedVertices = new ConcurrentHashMap<E, VertexPair<V>>(); /** * {@inheritDoc} @@ -123,7 +123,7 @@ public abstract class BaseGraph<V extend { return adjacencyList.containsKey( v ); } - + /** * {@inheritDoc} */ @@ -131,7 +131,7 @@ public abstract class BaseGraph<V extend { return indexedVertices.containsKey( e ); } - + /** * Returns the adjacency list where stored vertex/edges. * Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java?rev=1296087&r1=1296086&r2=1296087&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java Fri Mar 2 08:45:06 2012 @@ -19,10 +19,10 @@ package org.apache.commons.graph.model; * under the License. */ -import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.graph.DirectedGraph; import org.apache.commons.graph.Edge; @@ -42,9 +42,9 @@ public class DirectedMutableGraph<V exte private static final long serialVersionUID = 630111985439492792L; - private final Map<V, Set<V>> inbound = new HashMap<V, Set<V>>(); + private final Map<V, Set<V>> inbound = new ConcurrentHashMap<V, Set<V>>(); - private final Map<V, Set<V>> outbound = new HashMap<V, Set<V>>(); + private final Map<V, Set<V>> outbound = new ConcurrentHashMap<V, Set<V>>(); /** * {@inheritDoc} Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java?rev=1296087&r1=1296086&r2=1296087&view=diff ============================================================================== --- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java (original) +++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java Fri Mar 2 08:45:06 2012 @@ -19,16 +19,16 @@ package org.apache.commons.graph.model; * under the License. */ -import static org.apache.commons.graph.utils.Assertions.*; - -import static java.util.Arrays.asList; import static java.lang.String.format; +import static java.util.Arrays.asList; import static java.util.Collections.unmodifiableList; +import static org.apache.commons.graph.utils.Assertions.checkArgument; +import static org.apache.commons.graph.utils.Assertions.checkNotNull; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.graph.Edge; import org.apache.commons.graph.Path; @@ -56,11 +56,11 @@ public class InMemoryPath<V extends Vert private final LinkedList<E> edges = new LinkedList<E>(); - private final Map<V, V> successors = new HashMap<V, V>(); + private final Map<V, V> successors = new ConcurrentHashMap<V, V>(); - private final Map<VertexPair<V>, E> indexedEdges = new HashMap<VertexPair<V>, E>(); + private final Map<VertexPair<V>, E> indexedEdges = new ConcurrentHashMap<VertexPair<V>, E>(); - private final Map<E, VertexPair<V>> indexedVertices = new HashMap<E, VertexPair<V>>(); + private final Map<E, VertexPair<V>> indexedVertices = new ConcurrentHashMap<E, VertexPair<V>>(); public InMemoryPath( V start, V target ) { @@ -211,7 +211,7 @@ public class InMemoryPath<V extends Vert { return vertices.contains( v ); } - + /** * {@inheritDoc} */