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 |
/** |
/** |