You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2012/07/12 10:44:57 UTC
svn commit: r1360580 -
/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
Author: marcosperanza
Date: Thu Jul 12 08:44:56 2012
New Revision: 1360580
URL: http://svn.apache.org/viewvc?rev=1360580&view=rev
Log:
Fixed 'EqualsHashCode' checkstyle error, no functionl modifications.
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
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=1360580&r1=1360579&r2=1360580&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 Thu Jul 12 08:44:56 2012
@@ -143,6 +143,18 @@ public abstract class BaseGraph<V, E>
return adjacencyList;
}
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( adjacencyList == null ) ? 0 : adjacencyList.hashCode() );
+ result = prime * result + ( ( allEdges == null ) ? 0 : allEdges.hashCode() );
+ result = prime * result + ( ( indexedEdges == null ) ? 0 : indexedEdges.hashCode() );
+ result = prime * result + ( ( indexedVertices == null ) ? 0 : indexedVertices.hashCode() );
+ return result;
+ }
+
/**
* {@inheritDoc}
*/
Re: svn commit: r1360580 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
Posted by Marco Speranza <ma...@apache.org>.
hi simo
2012/7/12 Simone Tripodi <si...@apache.org>:
> good! IMHO this can be fixed using the
> org.apache.commons.graph.utils.Objects#hash() shortcut, i.e.
yep... I just fixed it :P
ciao
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1360580 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
Posted by Simone Tripodi <si...@apache.org>.
Hi Marco,
> + @Override
> + public int hashCode()
> + {
> + final int prime = 31;
> + int result = 1;
> + result = prime * result + ( ( adjacencyList == null ) ? 0 : adjacencyList.hashCode() );
> + result = prime * result + ( ( allEdges == null ) ? 0 : allEdges.hashCode() );
> + result = prime * result + ( ( indexedEdges == null ) ? 0 : indexedEdges.hashCode() );
> + result = prime * result + ( ( indexedVertices == null ) ? 0 : indexedVertices.hashCode() );
> + return result;
> + }
good! IMHO this can be fixed using the
org.apache.commons.graph.utils.Objects#hash() shortcut, i.e.
> import static org.apache.commons.graph.utils.Objects.hash;
> ...
> + @Override
> + public int hashCode()
> + {
> + final int prime = 31;
> + return hash( 1, prime, adjacencyList, allEdges, indexedEdges, indexedVertices );
> + }
best and thanks!
-Simo
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org