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

Diff of /classpath/java/nio/IntBuffer.java

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

revision 1.17 by tromey, Fri Aug 13 23:41:47 2004 UTC revision 1.18 by smarothy, Fri Sep 17 14:16:52 2004 UTC
# Line 243  public abstract class IntBuffer extends Line 243  public abstract class IntBuffer extends
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. Note that the hashcode is dependent
252       * on buffer content, and therefore is not useful if the buffer
253       * 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 = 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 += (get(i) + 30)*multiplier;
265          }
266        return hashCode;
267    }    }
268    
269    /**    /**

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

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