This is a hashcode function for the NameComponent, computed using Adler by content rather than by identity (same as .equals works).

2005-09-14    Audrius Meskauskas  <[EMAIL PROTECTED]>

* org/omg/CosNaming/NameComponent (hashCode): New method.


Index: org/omg/CosNaming/NameComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/org/omg/CosNaming/NameComponent.java,v
retrieving revision 1.3
diff -u -r1.3 NameComponent.java
--- org/omg/CosNaming/NameComponent.java        2 Jul 2005 20:32:59 -0000       
1.3
+++ org/omg/CosNaming/NameComponent.java        14 Sep 2005 19:06:22 -0000
@@ -40,6 +40,8 @@
 
 import org.omg.CORBA.portable.IDLEntity;
 
+import java.util.zip.Adler32;
+
 /**
  * The name component, a node in the multi-comonent name.
  *
@@ -115,4 +117,14 @@
   {
     return id + "." + kind;
   }
-}
\ No newline at end of file
+
+  /**
+   * Return the hashCode of this NameComponent.
+   */
+  public int hashCode()
+  {
+    Adler32 adler = new Adler32();
+    adler.update(toString().getBytes());
+    return (int) adler.getValue() & Integer.MAX_VALUE;
+  }
+}
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to