[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Patch: FYI: fix PR 23880
From: |
Tom Tromey |
Subject: |
[cp-patches] Patch: FYI: fix PR 23880 |
Date: |
01 Oct 2005 12:42:10 -0600 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
I'm checking this in.
This adds hashCode() methods in a few places as pointed out by PR
23880. I chose relatively simple computations; I doubt these hash
functions matter much as long as the general contract is satisfied.
Tom
2005-10-01 Tom Tromey <address@hidden>
PR classpath/23880:
* gnu/java/security/x509/ext/Extension.java (Value.hashCode): New
method.
* gnu/java/security/der/BitString.java (hashCode): New method.
* javax/security/auth/x500/X500Principal.java (hashCode): New method.
Index: gnu/java/security/der/BitString.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/der/BitString.java,v
retrieving revision 1.3
diff -u -r1.3 BitString.java
--- gnu/java/security/der/BitString.java 2 Jul 2005 20:32:14 -0000
1.3
+++ gnu/java/security/der/BitString.java 1 Oct 2005 18:46:26 -0000
@@ -286,6 +286,19 @@
return 0; // not reached.
}
+ public int hashCode()
+ {
+ int result = 0;
+ for (int i = 0; i < bytes.length - 1; ++i)
+ result = result * 31 + bytes[i];
+ if (bytes.length > 0)
+ {
+ int lastByte = bytes[bytes.length - 1] & ~ ((1 << ignoredBits) - 1);
+ result = result * 31 + lastByte;
+ }
+ return result;
+ }
+
public boolean equals(Object o)
{
if (!(o instanceof BitString))
Index: gnu/java/security/x509/ext/Extension.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/gnu/java/security/x509/ext/Extension.java,v
retrieving revision 1.4
diff -u -r1.4 Extension.java
--- gnu/java/security/x509/ext/Extension.java 14 Sep 2005 16:52:07 -0000
1.4
+++ gnu/java/security/x509/ext/Extension.java 1 Oct 2005 18:46:26 -0000
@@ -274,6 +274,14 @@
return (byte[]) encoded;
}
+ public int hashCode()
+ {
+ int result = 0;
+ for (int i = 0; i < encoded.length; ++i)
+ result = result * 31 + encoded[i];
+ return result;
+ }
+
public boolean equals(Object o)
{
if (!(o instanceof Value))
Index: javax/security/auth/x500/X500Principal.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/security/auth/x500/X500Principal.java,v
retrieving revision 1.10
diff -u -r1.10 X500Principal.java
--- javax/security/auth/x500/X500Principal.java 8 Aug 2005 03:02:00 -0000
1.10
+++ javax/security/auth/x500/X500Principal.java 1 Oct 2005 18:46:27 -0000
@@ -140,6 +140,22 @@
// Instance methods.
// ------------------------------------------------------------------------
+ public int hashCode()
+ {
+ int result = size();
+ for (int i = 0; i < size(); ++i)
+ {
+ Map m = (Map) components.get(i);
+ for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); )
+ {
+ Map.Entry e = (Map.Entry) it2.next();
+ // We don't bother looking at the value of the entry.
+ result = result * 31 + ((OID) e.getKey()).hashCode();
+ }
+ }
+ return result;
+ }
+
public boolean equals(Object o)
{
if (!(o instanceof X500Principal))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] Patch: FYI: fix PR 23880,
Tom Tromey <=