public class IntList
extends java.lang.Object
Constructor and Description |
---|
IntList()
create an IntList of default size
|
IntList(int initialCapacity) |
IntList(IntList list)
create a copy of an existing IntList
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(int value)
Appends the specified element to the end of this list
(将指定元素附加到此列表的末尾)
|
void |
add(int index, int value)
add the specified value at the specified index
(在指定索引处添加指定值)
|
boolean |
addAll(int index, IntList c)
Inserts all of the elements in the specified collection into this list at the specified position.
(将指定集合中的所有元素插入此列表的指定位置。)
|
boolean |
addAll(IntList c)
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()
Removes all of the elements from this list.
(从此列表中删除所有元素。)
|
boolean |
contains(int o)
Returns true if this list contains the specified element.
(如果此列表包含指定元素,则返回 true。)
|
boolean |
containsAll(IntList c)
Returns true if this list contains all of the elements of the specified collection.
(如果此列表包含指定集合的所有元素,则返回 true。)
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this list for equality.
(比较指定对象与此列表是否相等。)
|
int |
get(int index)
Returns the element at the specified position in this list.
(返回此列表中指定位置的元素。)
|
int |
hashCode()
Returns the hash code value for this list.
(返回此列表的哈希码值。)
|
int |
indexOf(int o)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
(返回此列表中第一次出现指定元素的索引,如果此列表不包含此元素,则返回 -1。)
|
boolean |
isEmpty()
Returns true if this list contains no elements.
(如果此列表不包含任何元素,则返回 true。)
|
int |
lastIndexOf(int o)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
(返回此列表中最后一次出现指定元素的索引,如果此列表不包含此元素,则返回 -1。)
|
int |
remove(int index)
Removes the element at the specified position in this list.
(移除此列表中指定位置的元素。)
|
boolean |
removeAll(IntList c)
Removes from this list all the elements that are contained in the specified collection
(从此列表中删除指定集合中包含的所有元素)
|
boolean |
removeValue(int o)
Removes the first occurrence in this list of the specified element (optional operation).
(删除此列表中第一个出现的指定元素(可选操作)。)
|
boolean |
retainAll(IntList c)
Retains only the elements in this list that are contained in the specified collection.
(仅保留此列表中包含在指定集合中的元素。)
|
int |
set(int index, int element)
Replaces the element at the specified position in this list with the specified element
(将此列表中指定位置的元素替换为指定元素)
|
int |
size()
Returns the number of elements in this list.
(返回此列表中的元素数。)
|
int[] |
toArray()
Returns an array containing all of the elements in this list in proper sequence.
(以正确的顺序返回包含此列表中所有元素的数组。)
|
int[] |
toArray(int[] a)
Returns an array containing all of the elements in this list in proper sequence.
(以正确的顺序返回包含此列表中所有元素的数组。)
|
public IntList()
public IntList(int initialCapacity)
public IntList(IntList list)
list
- the existing IntList
(list - 现有的 IntList)
public void add(int index, int value)
index
- the index where the new value is to be added
(index - 要添加新值的索引)
value
- the new value
(value - 新值)
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()).
(java.lang.IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index > size())。)
public boolean add(int value)
value
- element to be appended to this list.
(value - 要附加到此列表的元素。)
public boolean addAll(IntList c)
c
- collection whose elements are to be added to this list.
(c - 将其元素添加到此列表的集合。)
public boolean addAll(int index, IntList c)
index
- index at which to insert first element from the specified collection.
(index - 插入指定集合中第一个元素的索引。)
c
- elements to be inserted into this list.
(c - 要插入此列表的元素。)
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size())
(java.lang.IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index > size()))
public void clear()
public boolean contains(int o)
o
- element whose presence in this list is to be tested.
(o - 要测试其在此列表中的存在的元素。)
public boolean containsAll(IntList c)
c
- collection to be checked for containment in this list.
(c - 要检查的集合是否包含在此列表中。)
public boolean equals(java.lang.Object o)
equals
in class
java.lang.Object
o
- the object to be compared for equality with this list.
(o - 要与此列表比较是否相等的对象。)
public int get(int index)
index
- index of element to return.
(index - 要返回的元素的索引。)
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).
(java.lang.IndexOutOfBoundsException - 如果索引超出范围(索引 < 0 || 索引 >= size())。)
public int hashCode()
hashCode = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = i.next(); hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode()); }
This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object.hashCode.
(返回此列表的哈希码值。列表的哈希码定义为以下计算的结果: hashCode = 1;迭代器 i = list.iterator(); while (i.hasNext()) { 对象 obj = i.next(); hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());这确保了 list1.equals(list2) 意味着 list1.hashCode()==list2.hashCode() 对于任何两个列表 list1 和 list2,这是 Object.hashCode 的一般合同所要求的。)
hashCode
in class
java.lang.Object
public int indexOf(int o)
o
- element to search for.
(o - 要搜索的元素。)
public boolean isEmpty()
public int lastIndexOf(int o)
o
- element to search for.
(o - 要搜索的元素。)
public int remove(int index)
index
- the index of the element to removed.
(index - 要删除的元素的索引。)
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).
(java.lang.IndexOutOfBoundsException - 如果索引超出范围(索引 < 0 || 索引 >= size())。)
public boolean removeValue(int o)
o
- element to be removed from this list, if present.
(o - 要从此列表中删除的元素(如果存在)。)
public boolean removeAll(IntList c)
c
- collection that defines which elements will be removed from this list.
(c - 定义将从该列表中删除哪些元素的集合。)
public boolean retainAll(IntList c)
c
- collection that defines which elements this set will retain.
(c - 定义该集合将保留哪些元素的集合。)
public int set(int index, int element)
index
- index of element to replace.
(index - 要替换的元素的索引。)
element
- element to be stored at the specified position.
(element - 要存储在指定位置的元素。)
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).
(java.lang.IndexOutOfBoundsException - 如果索引超出范围(索引 < 0 || 索引 >= size())。)
public int size()
public int[] toArray()
public int[] toArray(int[] a)
a
- the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array is allocated for this purpose.
(a - 这个列表的元素要存储到的数组,如果它足够大的话;否则,为此目的分配一个新数组。)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.