public class Ints extends Object
| 构造器和说明 |
|---|
Ints() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
contains(int[] array,
int value)
数组中是否包含元素
|
static int |
indexOf(int[] array,
int value)
返回数组中指定元素所在位置,未找到返回 -1
|
static boolean |
isEmpty(int[] array)
数组是否为空
|
static boolean |
isNotEmpty(int[] array)
数组是否为非空
|
static boolean |
isSorted(int[] array)
检查数组是否升序,即array[i] <= array[i+1],若传入空数组,则返回false
|
static boolean |
isSortedAsc(int[] array)
检查数组是否升序,即array[i] <= array[i+1],若传入空数组,则返回false
|
static boolean |
isSortedDesc(int[] array)
检查数组是否降序,即array[i] >= array[i+1],若传入空数组,则返回false
|
static int[] |
join(int[]... arrays)
将多个数组合并在一起
忽略null的数组 |
static int |
lastIndexOf(int[] array,
int value)
返回数组中指定元素所在最后的位置,未找到返回 -1
|
static int |
max(int... numberArray)
取最大值
|
static int |
min(int... numberArray)
取最小值
|
static int[] |
range(int excludedEnd)
生成一个从0开始的数字列表
|
static int[] |
range(int includedStart,
int excludedEnd)
生成一个数字列表
自动判定正序反序 |
static int[] |
range(int includedStart,
int excludedEnd,
int step)
生成一个数字列表
自动判定正序反序 |
static int[] |
remove(int[] array,
int index)
移除数组中对应位置的元素
copy from commons-lang |
static int[] |
removeElement(int[] array,
int element)
移除数组中指定的元素
只会移除匹配到的第一个元素 copy from commons-lang |
static int[] |
reverse(int[] array)
反转数组,会变更原数组
|
static int[] |
reverse(int[] array,
int startIndexInclusive,
int endIndexExclusive)
反转数组,会变更原数组
|
static int[] |
shuffle(int[] array)
打乱数组顺序,会变更原数组
|
static int[] |
shuffle(int[] array,
Random random)
打乱数组顺序,会变更原数组
|
static int[] |
sub(int[] array,
int start,
int end)
获取子数组
|
static int[] |
swap(int[] array,
int index1,
int index2)
交换数组中两个位置的值
|
static int[] |
unwrap(Integer... values)
包装类数组转为原始类型数组,null转为0
|
static Integer[] |
wrap(int... values)
将原始类型数组包装为包装类型
|
public static boolean isEmpty(int[] array)
array - 数组public static boolean isNotEmpty(int[] array)
array - 数组public static int[] join(int[]... arrays)
arrays - 数组集合public static int[] range(int excludedEnd)
excludedEnd - 结束的数字(不包含)public static int[] range(int includedStart,
int excludedEnd)
includedStart - 开始的数字(包含)excludedEnd - 结束的数字(不包含)public static int[] range(int includedStart,
int excludedEnd,
int step)
includedStart - 开始的数字(包含)excludedEnd - 结束的数字(不包含)step - 步进public static int indexOf(int[] array,
int value)
array - 数组value - 被检查的元素public static int lastIndexOf(int[] array,
int value)
array - 数组value - 被检查的元素public static boolean contains(int[] array,
int value)
array - 数组value - 被检查的元素public static Integer[] wrap(int... values)
values - 原始类型数组public static int[] unwrap(Integer... values)
values - 包装类型数组public static int[] sub(int[] array,
int start,
int end)
array - 数组start - 开始位置(包括)end - 结束位置(不包括)Arrays.copyOfRange(Object[], int, int)public static int[] remove(int[] array,
int index)
throws IllegalArgumentException
array - 数组对象,可以是对象数组,也可以原始类型数组index - 位置,如果位置小于0或者大于长度,返回原数组IllegalArgumentException - 参数对象不为数组对象public static int[] removeElement(int[] array,
int element)
throws IllegalArgumentException
array - 数组对象,可以是对象数组,也可以原始类型数组element - 要移除的元素IllegalArgumentException - 参数对象不为数组对象public static int[] reverse(int[] array,
int startIndexInclusive,
int endIndexExclusive)
array - 数组,会变更startIndexInclusive - 起始位置(包含)endIndexExclusive - 结束位置(不包含)public static int[] reverse(int[] array)
array - 数组,会变更public static int min(int... numberArray)
numberArray - 数字数组public static int max(int... numberArray)
numberArray - 数字数组public static int[] shuffle(int[] array)
array - 数组,会变更public static int[] shuffle(int[] array,
Random random)
array - 数组,会变更random - 随机数生成器public static int[] swap(int[] array,
int index1,
int index2)
array - 数组index1 - 位置1index2 - 位置2public static boolean isSorted(int[] array)
array - 数组public static boolean isSortedAsc(int[] array)
array - 数组public static boolean isSortedDesc(int[] array)
array - 数组Copyright © 2024 fossc. All rights reserved.