| Arrays类 |
|
|
|
| 属性/方法 |
修饰 |
参数 |
说明 |
| .binarySearch() |
static int |
type[] a, type key |
使用二分法查询key元素值在a数组中出现的索引; 如果a数组不包含key元素, 则返回负数. (数组必须已经按升序排列) |
| type[] a, int formIndex, int toIndex, type key |
同上, 不过只搜索a数组中fromIndex到toIndex索引的元素 |
| .copyOf() |
static type[] |
type[] original, int length |
把original数组复制成一个新数组, 其中length是数组的长度. 如果length小于original数组的长度, 则新数组就是原数组前length个元素; 若大于, 则新数组是在原数组基础上向后补充对应类型的默认值 |
| .copyOfRange() |
static type[] |
type[] original, int from, int to |
复制original数组的from索引到to索引的元素到新数组 |
| .equals() |
static boolean |
type[] a, type[] a2 |
若两数组长度相同且元素也一一相同则返回true |
| .fill() |
static type[] |
type[] a, type val |
把a数组的所有元素都赋值为val |
| type[] a, int fromIndex, int toIndex, type val |
只对范围内的赋值 |
| .sort() |
static type[] |
type[] a |
对a数组的元素进行排序 |
| type[] a, int fromIndex, toIndex |
只对范围内的进行排序 |
| java 8 为Arrays类增加的一些工具方法, 主要增强了并发能力 |
|
| .parallelPrefix() |
static void |
xxx[] array, XxxBinaryOperator op |
使用op参数指定的计算公式计算得到的结果作为新的元素. op计算公式包括left、right两个形参, 其中left代表数组中前一个索引处的元素, right代表数组中当前索引处的元素, 当计算第一个新组元素时, left的值默认为1 |
| xxx[] array, int fromIndex, int toIndex, XxxBinaryOperator op |
计算范围内的 |
| .setAll() |
static void |
xxx[] array, IntToXxxFunction generator |
使用指定的生成器(generator)为所有数组元素设置值, 该生成器控制数组元素值得生成算法 |
| .parallelSetAll() |
static void |
xxx[] array, IntToXxxFunction generator |
同上, 不过增加了并行能力 |
| .parallelSort() |
static void |
参考.sort() |
功能与.sort()类似, 不过增加了并行能力 |
| .spliterator() |
static Splitertor. OfXxx |
xxx[] array |
将数组所有元素转换成对应的Spliterator对象 |
| xxx[] array, int startInclusive, int endExclusive |
只对范围内的进行操作 |
| .stream() |
static XxxStream |
参考.spliterator() |
将数组转换为Stream, Stream是Java 8新增的流式编程的API |
| |
|
|
|