< prev index next >
src/java.base/share/classes/java/lang/StringLatin1.java
Print this page
*** 146,155 ****
--- 146,168 ----
}
}
return len1 - len2;
}
+ /**
+ * hashCode consistent with {@link #compareToCI}
+ */
+ public static int hashCodeCI(byte[] value) {
+ int h = 0;
+ for (byte v : value) {
+ char cu = (char) CharacterDataLatin1.instance.toUpperCase(v & 0xff);
+ char cl = (char) CharacterDataLatin1.instance.toLowerCase(cu);
+ h = 31 * h + cl;
+ }
+ return h;
+ }
+
public static int compareToCI_UTF16(byte[] value, byte[] other) {
int len1 = length(value);
int len2 = StringUTF16.length(other);
int lim = Math.min(len1, len2);
for (int k = 0; k < lim; k++) {
< prev index next >