Strange dance mobile technology

The structures of List, Set and Map are sorted out previously. In the Java container system, there are also two very important utility classes Collections and Arrays. This paper mainly reviews the methods provided by the Arrays class.

The sorting

Arrays provides two sorts: Sort and parallelSort. Let’s look at the functions associated with sort first:

Arrays
sort
sort
int
long
short
char
byte
float
double
boolean
sort
int
sort
Object
Comparator

MIN_ARRAY_SORT_GRAN
parallelSort
sort
parallelSort
boolean
Comparator

The binary operation

Int [] arr = new int [] {1,2,3,4,5,6}; Arrays.parallelPrefix(arr, new IntBinaryOperator() { @Override public int applyAsInt(int left, int right) { // TODO Auto-generated method stub System.out.println(left + "-" + right); return left + right; }}); System.out.println(Arrays.toString(arr)); 1-2 3-3 6-4 10-5 15-6 [1, 3, 6, 10, 15, 21]Copy the code

ParallelPrefix provides the IntBinarryOperator interface. ApplyAsInt provides the left and right parameters to modify the array, and writes the result to the original array. Binary operations can operate on arrays of types long, int, double, or any other type, and can provide a range of subscripts for array operations.

Binary search

Arrays
boolean
Comparator

The data

fill

copy

copyOf
copyRangeOf

Iterative segmentation



Java iterator spliterator



Java iterator spliterator

Stream

stream

conclusion

Arrays mainly provides sorting, binary operation, binary search, data filling, copy, segmentation iteration and streaming processing operations. This article introduces the functionality, but does not explain it in detail. There will be two subsequent articles on split iteration and streaming processing.

Pay attention to wechat public number, the latest technology dry goods real-time push