You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/06/11 23:22:16 UTC
svn commit: r1134765 -
/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java
Author: simonetripodi
Date: Sat Jun 11 21:22:16 2011
New Revision: 1134765
URL: http://svn.apache.org/viewvc?rev=1134765&view=rev
Log:
returned set have to be read-only data structures
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java
Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java?rev=1134765&r1=1134764&r2=1134765&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/UndirectedGraphImpl.java Sat Jun 11 21:22:16 2011
@@ -19,6 +19,8 @@ package org.apache.commons.graph.domain.
* under the License.
*/
+import static java.util.Collections.unmodifiableSet;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -155,7 +157,7 @@ public class UndirectedGraphImpl<V exten
*/
public Set<V> getVertices()
{
- return new HashSet( vertices );
+ return unmodifiableSet( vertices );
}
/**
@@ -165,7 +167,7 @@ public class UndirectedGraphImpl<V exten
{
if ( edgeVerts.containsKey( e ) )
{
- return new HashSet( edgeVerts.get( e ) );
+ return unmodifiableSet( edgeVerts.get( e ) );
}
else
{
@@ -178,7 +180,7 @@ public class UndirectedGraphImpl<V exten
*/
public Set<WE> getEdges()
{
- return new HashSet( edges );
+ return unmodifiableSet( edges );
}
/**
@@ -188,7 +190,7 @@ public class UndirectedGraphImpl<V exten
{
if ( vertEdges.containsKey( v ) )
{
- return new HashSet( vertEdges.get( v ) );
+ return unmodifiableSet( vertEdges.get( v ) );
}
else
{