@@ -203,67 +203,6 @@ private static boolean equalsNumChar(java.lang.Number xn, java.lang.Character yc
203
203
}
204
204
}
205
205
206
- /** Hashcode algorithm is driven by the requirements imposed
207
- * by primitive equality semantics, namely that equal objects
208
- * have equal hashCodes. The first priority are the integral/char
209
- * types, which already have the same hashCodes for the same
210
- * values except for Long. So Long's hashCode is altered to
211
- * conform to Int's for all values in Int's range.
212
- *
213
- * Float is problematic because it's far too small to hold
214
- * all the Ints, so for instance Int.MaxValue.toFloat claims
215
- * to be == to each of the largest 64 Ints. There is no way
216
- * to preserve equals/hashCode alignment without compromising
217
- * the hashCode distribution, so Floats are only guaranteed
218
- * to have the same hashCode for whole Floats in the range
219
- * Short.MinValue to Short.MaxValue (2^16 total.)
220
- *
221
- * Double has its hashCode altered to match the entire Int range,
222
- * but is not guaranteed beyond that. (But could/should it be?
223
- * The hashCode is only 32 bits so this is a more tractable
224
- * issue than Float's, but it might be better simply to exclude it.)
225
- *
226
- * Note: BigInt and BigDecimal, being arbitrary precision, could
227
- * be made consistent with all other types for the Int range, but
228
- * as yet have not.
229
- *
230
- * Note: Among primitives, Float.NaN != Float.NaN, but the boxed
231
- * verisons are equal. This still needs reconciliation.
232
- */
233
- public static int hashFromLong (java .lang .Long n ) {
234
- int iv = n .intValue ();
235
- if (iv == n .longValue ()) return iv ;
236
- else return n .hashCode ();
237
- }
238
- public static int hashFromDouble (java .lang .Double n ) {
239
- int iv = n .intValue ();
240
- double dv = n .doubleValue ();
241
- if (iv == dv ) return iv ;
242
-
243
- long lv = n .longValue ();
244
- if (lv == dv ) return java .lang .Long .valueOf (lv ).hashCode ();
245
- else return n .hashCode ();
246
- }
247
- public static int hashFromFloat (java .lang .Float n ) {
248
- int iv = n .intValue ();
249
- float fv = n .floatValue ();
250
- if (iv == fv ) return iv ;
251
-
252
- long lv = n .longValue ();
253
- if (lv == fv ) return java .lang .Long .valueOf (lv ).hashCode ();
254
- else return n .hashCode ();
255
- }
256
- public static int hashFromNumber (java .lang .Number n ) {
257
- if (n instanceof java .lang .Long ) return hashFromLong ((java .lang .Long )n );
258
- else if (n instanceof java .lang .Double ) return hashFromDouble ((java .lang .Double )n );
259
- else if (n instanceof java .lang .Float ) return hashFromFloat ((java .lang .Float )n );
260
- else return n .hashCode ();
261
- }
262
- public static int hashFromObject (Object a ) {
263
- if (a instanceof Number ) return hashFromNumber ((Number )a );
264
- else return a .hashCode ();
265
- }
266
-
267
206
private static int unboxCharOrInt (Object arg1 , int code ) {
268
207
if (code == CHAR )
269
208
return ((java .lang .Character ) arg1 ).charValue ();
0 commit comments