MCPcopy Create free account
hub / github.com/davidgiven/luje / compareTo

Method compareTo

lib/java/lang/String.java:602–613  ·  view source on GitHub ↗

Compares the specified string to this string using the Unicode values of the characters. Returns 0 if the strings contain the same characters in the same order. Returns a negative integer if the first non-equal character in this string has a Unicode value which is less than the Unicode value of the

(String string)

Source from the content-addressed store, hash-verified

600 * if {@code string} is {@code null}.
601 */
602 public int compareTo(String string) {
603 // Code adapted from K&R, pg 101
604 int o1 = offset, o2 = string.offset, result;
605 int end = offset + (count < string.count ? count : string.count);
606 char[] target = string.value;
607 while (o1 < end) {
608 if ((result = value[o1++] - target[o2++]) != 0) {
609 return result;
610 }
611 }
612 return count - string.count;
613 }
614
615 /**
616 * Compares the specified string to this string using the Unicode values of

Callers 1

stableStringSortMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected