-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstant.java
More file actions
50 lines (43 loc) · 1.3 KB
/
Constant.java
File metadata and controls
50 lines (43 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package Sorting.src;
import java.util.Arrays;
import java.util.stream.Collectors;
/**
* 定义排序用的常量,公共方法
*
* 这里最好使用泛型类,更通用
*
*
* @time 2018年3月24日14:39:51
*/
public abstract class Constant {
public static final Object[] array = {8, 34, 64, 51, 33, 22, 44, 55, 88, 1, 0, 2, 2};
public static final Integer[] numsBefore = {0, 2, 3, 6, 5, 4, -1, -2, 0, Integer.MIN_VALUE, Integer.MAX_VALUE};
// 有序数组
public static final Object[] array2 = {0, 1, 2, 2, 8, 22, 33, 34, 44, 51, 55, 64, 88};
public static final int len = array.length;
public static void printResult(Object[] array) throws Exception {
if (array == null || array.length == 0)
throw new Exception("no element or invalid element in array");
// java 8 lambda
//System.out.println(Arrays.stream(array).map(x -> x.toString()).collect(Collectors.joining(",", "[", "]")));
OutUtil.print(array,1);
}
/**
* 原始版
*
* @param array
* @param len
* @return
*/
public abstract Object[] sort(Object[] array, int len);
/**
* 优化版
*
* @param array
* @param len
* @return
*/
public Object[] sort2(Object[] array, int len) {
return new Object[0];
}
}