Missed OtpErlangTuple.hashCode()

Shawn Pearce spearce@REDACTED
Fri Jan 26 07:02:48 CET 2001


My last patch missed OtpErlangTuple's hashCode() method.  This patch
replaces the last one, as it includes the new method, plus everthing
else.

--
Shawn.

  ``If this had been a real
    life, you would have
    received instructions
    on where to go and what
    to do.''


diff -r -c otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangAtom.java otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangAtom.java
*** otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangAtom.java	Tue Aug 22 08:01:26 2000
--- otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangAtom.java	Thu Jan 25 23:49:58 2001
***************
*** 135,140 ****
--- 135,149 ----
    }
  
    /**
+    * Get the hashcode of the atom value.
+    *
+    * @return hashCode of atomValue().
+    **/
+   public int hashCode() {
+   	return this.atom.hashCode();
+   }
+ 
+   /**
     * Convert this atom to the equivalent Erlang external representation.
     *
     * @param buf an output stream to which the encoded atom should be
diff -r -c otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangBinary.java otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangBinary.java
*** otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangBinary.java	Tue Aug 22 08:01:29 2000
--- otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangBinary.java	Thu Jan 25 23:58:42 2001
***************
*** 180,186 ****
  
      return true;
    }
!   
    public Object clone() {
      OtpErlangBinary newBin = (OtpErlangBinary)(super.clone());
      newBin.bin = (byte[])bin.clone();
--- 180,196 ----
  
      return true;
    }
! 
!   public int hashCode() {
!   	int		hc = 0;
! 
! 	int size = this.size();
!   	for(int x = 0; x < size; x++) {
! 		hc += this.bin[x];
! 	}
!     return hc;
!   }
! 
    public Object clone() {
      OtpErlangBinary newBin = (OtpErlangBinary)(super.clone());
      newBin.bin = (byte[])bin.clone();
diff -r -c otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangDouble.java otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangDouble.java
*** otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangDouble.java	Tue Aug 22 08:01:40 2000
--- otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangDouble.java	Thu Jan 25 23:53:20 2001
***************
*** 113,116 ****
--- 113,121 ----
      OtpErlangDouble d = (OtpErlangDouble)o;
      return this.d == d.d;
    }
+ 
+   public int hashCode() {
+     return (int)(d * 100);
+   }
+ 
  }
diff -r -c otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangList.java otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangList.java
*** otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangList.java	Tue Aug 22 08:01:50 2000
--- otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangList.java	Thu Jan 25 23:54:26 2001
***************
*** 230,235 ****
--- 230,244 ----
      return true;
    }
  
+   public int hashCode() {
+     int a = this.arity();
+ 	int hc = 0;
+ 	for (int i = 0; i < a; i++) {
+ 		hc += this.elems[i].hashCode();
+ 	}
+   	return hc;
+   }
+ 
    public Object clone() {
      OtpErlangList newList = (OtpErlangList)(super.clone());
      newList.elems = (OtpErlangObject[])elems.clone();
diff -r -c otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangLong.java otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangLong.java
*** otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangLong.java	Tue Aug 22 08:01:52 2000
--- otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangLong.java	Thu Jan 25 23:54:44 2001
***************
*** 222,225 ****
--- 222,229 ----
      OtpErlangLong l = (OtpErlangLong)o;
      return this.val == l.val;
    }
+ 
+   public int hashCode() {
+   	return (int)this.val;
+   }
  }
diff -r -c otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangTuple.java otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangTuple.java
*** otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangTuple.java	Tue Aug 22 08:02:14 2000
--- otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangTuple.java	Fri Jan 26 00:59:31 2001
***************
*** 105,113 ****
        this.elems = new OtpErlangObject[arity];
  
        for (int i=0; i<arity; i++) {
! 	elems[i] = buf.read_any();
!       }
!     }
    }
  
    /**
--- 105,115 ----
        this.elems = new OtpErlangObject[arity];
  
        for (int i=0; i<arity; i++) {
! 	    elems[i] = buf.read_any();
! 	  }
!     } else {
! 	  this.elems = new OtpErlangObject[0];
! 	}
    }
  
    /**
***************
*** 206,211 ****
--- 208,222 ----
      }
  
      return true;
+   }
+ 
+   public int hashCode() {
+     int a = this.arity();
+ 	int hc = 0;
+ 	for (int i = 0; i < a; i++) {
+ 		hc += this.elems[i].hashCode();
+ 	}
+   	return hc;
    }
  
    public Object clone() {
diff -r -c otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java
*** otp_src_R7B-0.orig/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java	Tue Aug 22 08:05:26 2000
--- otp_src_R7B-0/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java	Fri Jan 12 22:13:59 2001
***************
*** 610,616 ****
        this.setDaemon(true);
        this.setName("acceptor");
        publishPort();
!       acceptor.start();
      }
  
      private boolean publishPort() 
--- 610,616 ----
        this.setDaemon(true);
        this.setName("acceptor");
        publishPort();
!       this.start();
      }
  
      private boolean publishPort() 



More information about the erlang-questions mailing list