@Test public void testGetMinAndMaxCharacter() { Pair<Character, Character> result = RangeSplitUtil.getMinAndMaxCharacter("abc%^&"); Assert.assertEquals('%', result.getLeft().charValue()); Assert.assertEquals('c', result.getRight().charValue()); result = RangeSplitUtil.getMinAndMaxCharacter("\tAabcZx"); Assert.assertEquals('\t', result.getLeft().charValue()); Assert.assertEquals('x', result.getRight().charValue()); }
public static Pair<Character, Character> getMinAndMaxCharacter(String aString) { if (!isPureAscii(aString)) { throw new IllegalArgumentException(String.format("根据字符串进行切分时仅支持 ASCII 字符串，而字符串:[%s]非 ASCII 字符串.", aString)); } char min = aString.charAt(0); char max = min; char temp; for (int i = 1, len = aString.length(); i < len; i++) { temp = aString.charAt(i); min = min < temp ? min : temp; max = max > temp ? max : temp; } return new ImmutablePair<Character, Character>(min, max); }
RangeSplitUtil { public static Pair<Character, Character> getMinAndMaxCharacter(String aString) { if (!isPureAscii(aString)) { throw new IllegalArgumentException(String.format("根据字符串进行切分时仅支持 ASCII 字符串，而字符串:[%s]非 ASCII 字符串.", aString)); } char min = aString.charAt(0); char max = min; char temp; for (int i = 1, len = aString.length(); i < len; i++) { temp = aString.charAt(i); min = min < temp ? min : temp; max = max > temp ? max : temp; } return new ImmutablePair<Character, Character>(min, max); } }
RangeSplitUtil { public static Pair<Character, Character> getMinAndMaxCharacter(String aString) { if (!isPureAscii(aString)) { throw new IllegalArgumentException(String.format("根据字符串进行切分时仅支持 ASCII 字符串，而字符串:[%s]非 ASCII 字符串.", aString)); } char min = aString.charAt(0); char max = min; char temp; for (int i = 1, len = aString.length(); i < len; i++) { temp = aString.charAt(i); min = min < temp ? min : temp; max = max > temp ? max : temp; } return new ImmutablePair<Character, Character>(min, max); }  }
RangeSplitUtil { public static Pair<Character, Character> getMinAndMaxCharacter(String aString) { if (!isPureAscii(aString)) { throw new IllegalArgumentException(String.format("根据字符串进行切分时仅支持 ASCII 字符串，而字符串:[%s]非 ASCII 字符串.", aString)); } char min = aString.charAt(0); char max = min; char temp; for (int i = 1, len = aString.length(); i < len; i++) { temp = aString.charAt(i); min = min < temp ? min : temp; max = max > temp ? max : temp; } return new ImmutablePair<Character, Character>(min, max); }  static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber); static long[] doLongSplit(long left, long right, int expectSliceNumber); static BigInteger[] doBigIntegerSplit(BigInteger left, BigInteger right, int expectSliceNumber); static BigInteger stringToBigInteger(String aString, int radix); static Pair<Character, Character> getMinAndMaxCharacter(String aString); }
RangeSplitUtil { public static Pair<Character, Character> getMinAndMaxCharacter(String aString) { if (!isPureAscii(aString)) { throw new IllegalArgumentException(String.format("根据字符串进行切分时仅支持 ASCII 字符串，而字符串:[%s]非 ASCII 字符串.", aString)); } char min = aString.charAt(0); char max = min; char temp; for (int i = 1, len = aString.length(); i < len; i++) { temp = aString.charAt(i); min = min < temp ? min : temp; max = max > temp ? max : temp; } return new ImmutablePair<Character, Character>(min, max); }  static String[] doAsciiStringSplit(String left, String right, int expectSliceNumber); static long[] doLongSplit(long left, long right, int expectSliceNumber); static BigInteger[] doBigIntegerSplit(BigInteger left, BigInteger right, int expectSliceNumber); static BigInteger stringToBigInteger(String aString, int radix); static Pair<Character, Character> getMinAndMaxCharacter(String aString);  }