| 构造器和说明 |
|---|
IntArrayList()
构建一个空的列表.
|
IntArrayList(int initialCapacity)
指定容量的方式构建一个IntList.
|
IntArrayList(int[] array)
直接传入一个数组进行初始化.
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
add(int e)
将指定的元素添加到此列表的尾部。
|
boolean |
addAll(int[] a)
Appends all of the elements in the specified collection to the end of
this list, in the order that they are returned by the specified
collection's Iterator.
|
void |
clear()
移除此列表中的所有元素。
|
boolean |
contains(int o)
如果此列表中包含指定的元素,则返回 true。
|
boolean |
equals(java.lang.Object obj) |
void |
forEach(java.util.function.Consumer<? super java.lang.Integer> action) |
int |
get(int index)
获取指定下标的数值.
|
int |
hashCode() |
int |
indexOf(int o)
查找指定数值.
|
boolean |
isEmpty()
如果此列表中没有元素,则返回 true
|
int |
lastIndexOf(int x)
返回此列表中最后出现的指定元素的索引.
|
int |
random()
从列表中随机出一个元素.
|
boolean |
remove(int o)
移除此列表中首次出现的指定元素(如果存在)。
|
int |
size()
返回列表中的元素个数。
|
int[] |
toArray()
按适当顺序(从第一个到最后一个元素)返回包含此列表中所有元素的数组。
|
void |
trimToSize()
将此IntArrayList实例的容量调整为列表的当前大小。
|
public IntArrayList()
public IntArrayList(int initialCapacity)
initialCapacity - 初始容量public IntArrayList(int[] array)
array - 一个数组public void trimToSize()
应用程序可以使用此操作来最小化 IntArrayList实例的存储量。
public boolean isEmpty()
IntListpublic boolean contains(int o)
IntList更确切地讲,当且仅当此列表包含至少一个满足 (o==e) 的元素 e 时,则返回 true。
public int indexOf(int o)
IntListpublic int lastIndexOf(int x)
IntList
如果列表不包含此元素,则返回 -1。
更确切地讲,返回满足 (get(i)==x) 的最高索引 i;
如果没有这样的索引,则返回 -1。
lastIndexOf 在接口中 IntListx - 要搜索的元素public int[] toArray()
IntList
由于此列表不维护对返回数组的任何引用,,因而它将是“安全的”。(换句话说,此方法必须分配一个新的数组)
因此,调用者可以自由地修改返回的数组。
public int get(int index)
IntListpublic boolean add(int e)
IntListpublic boolean remove(int o)
IntList
如果列表不包含此元素,则列表不做改动。更确切地讲,移除满足 (o==e) 的最低索引的元素(如果存在此类元素)。
如果列表中包含指定的元素,则返回 true(或者等同于这种情况:如果列表由于调用而发生更改,则返回 true)。
public boolean addAll(int[] a)
a - collection containing elements to be added to this listjava.lang.NullPointerException - if the specified collection is nullpublic int hashCode()
hashCode 在类中 java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals 在类中 java.lang.Objectpublic void forEach(java.util.function.Consumer<? super java.lang.Integer> action)