/[classpath]/classpath/java/nio/FloatBuffer.java
ViewVC logotype

Diff of /classpath/java/nio/FloatBuffer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16.2.1 by gnu_andrew, Thu Jan 13 22:40:38 2005 UTC revision 1.16.2.2 by gnu_andrew, Fri Jan 14 10:24:16 2005 UTC
# Line 243  public abstract class FloatBuffer extend Line 243  public abstract class FloatBuffer extend
243    
244    /**    /**
245     * Calculates a hash code for this buffer.     * Calculates a hash code for this buffer.
246       *
247       * This is done with <code>int</code> arithmetic,
248       * where ** represents exponentiation, by this formula:<br>
249       * <code>s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... +
250       * (s[limit()-1]+30)*31**(limit()-1)</code>.
251       * Where s is the buffer data, in Float.floatToIntBits() form
252       * Note that the hashcode is dependent on buffer content,
253       * and therefore is not useful if the buffer content may change.
254       *
255       * @return the hash code
256     */     */
257    public int hashCode ()    public int hashCode ()
258    {    {
259      // FIXME: Check what SUN calculates here.      int hashCode = Float.floatToIntBits(get(position())) + 31;
260      return super.hashCode ();      int multiplier = 1;
261        for (int i = position() + 1; i < limit(); ++i)
262          {
263              multiplier *= 31;
264              hashCode += (Float.floatToIntBits(get(i)) + 30)*multiplier;
265          }
266        return hashCode;
267    }    }
268    
269    /**    /**

Legend:
Removed from v.1.16.2.1  
changed lines
  Added in v.1.16.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26