binarySearch()
static int |
**binarySearch**(byte[] a, byte key) 使用二分搜索算法搜索指定值的指定字节数组。 |
---|---|
static int |
**binarySearch**(byte[] a, int fromIndex, int toIndex, byte key) 使用二分搜索算法搜索指定值的指定字节数组的范围。 |
static int |
**binarySearch**(char[] a, char key) 使用二分搜索算法搜索指定数组的指定值。 |
static int |
**binarySearch**(char[] a, int fromIndex, int toIndex, char key) 使用二分搜索算法搜索指定值的指定数组的范围。 |
static int |
**binarySearch**(double[] a, double key) 使用二分搜索算法搜索指定值的指定数组的双精度值。 |
static int |
**binarySearch**(double[] a, int fromIndex, int toIndex, double key) 使用二分搜索算法搜索指定值的指定数组的双精度范围。 |
static int |
**binarySearch**(float[] a, float key) 使用二分搜索算法搜索指定数组的浮点数。 |
static int |
**binarySearch**(float[] a, int fromIndex, int toIndex, float key) 使用二分搜索算法搜索指定数组的浮点数范围。 |
static int |
**binarySearch**(int[] a, int key) 使用二分搜索算法搜索指定的int数组的指定值。 |
static int |
**binarySearch**(int[] a, int fromIndex, int toIndex, int key) 使用二分搜索算法搜索指定值的指定数组的范围。 |
static int |
**binarySearch**(long[] a, int fromIndex, int toIndex, long key) 使用二分搜索算法搜索指定值的指定数组的范围。 |
static int |
**binarySearch**(long[] a, long key) 使用二分搜索算法搜索指定数组的指定数组。 |
static int |
**binarySearch**([Object](../../java/lang/Object.html)[] a, int fromIndex, int toIndex, [Object](../../java/lang/Object.html) key) 使用二分搜索算法搜索指定对象的指定数组的范围。 |
static int |
**binarySearch**([Object](../../java/lang/Object.html)[] a, [Object](../../java/lang/Object.html) key) 使用二分搜索算法搜索指定对象的指定数组。 |
static int |
**binarySearch**(short[] a, int fromIndex, int toIndex, short key) 使用二分搜索算法搜索指定值的指定数组的短整型范围。 |
static int |
**binarySearch**(short[] a, short key) 使用二分搜索算法搜索指定值的指定数组的指定值。 |
static <T> int |
**binarySearch**(T[] a, int fromIndex, int toIndex, T key, [Comparator](../../java/util/Comparator.html)<? super T> c) 使用二分搜索算法搜索指定对象的指定数组的范围。 |
static <T> int |
**binarySearch**(T[] a, T key, [Comparator](../../java/util/Comparator.html)<? super T> c) 使用二分搜索算法搜索指定对象的指定数组。 |
待查询数组必须有序,无序结果未定义。 待查元素在数组中如果出现多次,结果不定
返回值:如果该元素出现在数组中,返回其下标。如果该元素不存在于数组中,返回其应该被插入的位置,即返回第一个大于该元素值的下标或者数组长度表示应该被插入到末尾
sort()
除了默认只给待排数组外,还可以指定开始和结束的下标,左闭右开
对于引用类型,还可以使用自定义排序,参数在末尾。
stream()
static IntStream | stream (int[] array) 返回顺序IntStream与指定的数组作为源。 |
---|---|
static IntStream | stream (int[] array, int startInclusive, int endExclusive) 返回顺序IntStream与指定的数组作为源的指定范围。 |
用数组生成数字流,然后可以求sum()
以及max().getAsInt()