分享
 
 
 

java.util.AbstractList翻译

王朝java/jsp·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

[/url] [url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview

Package

Class

Use

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Std. Ed. v1.4.2

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

java.util

Class AbstractListjava.lang.Object

java.util.AbstractCollection

java.util.AbstractList

All Implemented Interfaces: Collection, List Direct Known Subclasses: AbstractSequentialList, ArrayList, Vector public abstract class AbstractList extends AbstractCollection implements ListThis class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array). For sequential access data (such as a linked list), AbstractSequentialList should be used in preference to this class. 该类提供了接口List的框架实现,用来降低实现该接口(由随机访问的数据存储,比如数组)的复杂程度。 对于数据的连续访问,比如链表,应该优先采用AbstractSequentialList类

To implement an unmodifiable list, the programmer needs only to extend this class and provide implementations for the get(int index) and size() methods. 为了实现一个不可修改的列表,程序员只需要继承该类,提供get(int index)和size()方法的实现即可。

To implement a modifiable list, the programmer must additionally override the set(int index, Object element) method (which otherwise throws an UnsupportedOperationException. If the list is variable-size the programmer must additionally override the add(int index, Object element) and remove(int index) methods. 为了实现一个可修改的列表,程序员必须另外重写该类的set(int index, Object element)方法 (否则总是抛出UnsupportedOperationException)。如果列表大小可变,程序员必须重写 add(int index, Object element)和remove(int index)方法。

The programmer should generally provide a void (no argument) and collection constructor, as per the recommendation in the Collection interface specification. 根据Collection接口文档的推荐,程序员通常提供一个空(不含参数)的Collection构造函数。

Unlike the other abstract collection implementations, the programmer does not have to provide an iterator implementation; the iterator and list iterator are implemented by this class, on top the "random access" methods: get(int index), set(int index, Object element), set(int index, Object element), add(int index, Object element) and remove(int index). 和其它抽象集合的实现不同,程序员不必提供迭代器的实现,迭代器和列表迭代器由本类 实现,在以下随机访问方法中使用:get(int index)、set(int index, Object element)、 set(int index, Object element)、add(int index, Object element)和remove(int index)。

The documentation for each non-abstract methods in this class describes its implementation in detail. Each of these methods may be overridden if the collection being implemented admits a more efficient implementation. 文档对该类的每一个非抽象方法描述了实现细节。这些方法中的每一个都可以被重写, 如果集合采取了更有效的实现方式。

This class is a member of the Java Collections Framework. 该接口是Java集合框架成员之一。

Since: 1.2 See Also: Collection, List, AbstractSequentialList, AbstractCollectionField Summary

protected int

modCount

The number of times this list has been structurally modified. 列表结构被修改的次数。

Constructor Summary

protected

AbstractList()

Sole constructor. 唯一的构造函数。

Method Summary

void

add(int index, Object element)

Inserts the specified element at the specified position in this list (optional operation). 在列表指定位置插入指定元素(可选操作)。

boolean

add(Object o)

Appends the specified element to the end of this List (optional operation). 在列表尾部添加指定元素(可选操作)。

boolean

addAll(int index, Collection c)

Inserts all of the elements in the specified collection into this list at the specified position (optional operation). 在列表指定位置插入指定集合的所有元素(可选操作)。

void

clear()

Removes all of the elements from this collection (optional operation). 删除集合的所有元素(可选操作)。

boolean

equals(Object o)

Compares the specified object with this list for equality. 将当前列表和指定对象就相等性进行比较。

abstract Object

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(Object o)

Returns the index in this list of the first occurence of the specified element, or -1 if the list does not contain this element. 返回指定元素在列表中第一次出现的位置,如果不含该元素,返回-1。

Iterator

iterator()

Returns an iterator over the elements in this list in proper sequence. 以适当的顺序返回列表元素的迭代器。

int

lastIndexOf(Object o)

Returns the index in this list of the last occurence of the specified element, or -1 if the list does not contain this element. 返回指定元素在列表中最后一次出现的位置,如果不含该元素,返回-1。

ListIterator

listIterator()

Returns an iterator of the elements in this list (in proper sequence). 以适当的顺序返回列表元素的迭代器。

ListIterator

listIterator(int index)

Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in the list. 从列表指定位置开始,以适当的顺序返回列表元素的列表迭代器。

Object

remove(int index)

Removes the element at the specified position in this list (optional operation). 删除列表中指定位置的元素(可选操作)。

protected void

removeRange(int fromIndex, int toIndex)

Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive. 删除从fromIndex(包括)到toIndex(不包括)位置间的列表所有元素。

Object

set(int index, Object element)

Replaces the element at the specified position in this list with the specified element (optional operation). 用指定元素替换指定位置的元素(可选操作)。

List

subList(int fromIndex, int toIndex)

Returns a view of the portion of this list between fromIndex, inclusive, and toIndex, exclusive. 返回从fromIndex(包括)到toIndex(不包括)位置间的部分列表视图。

Methods inherited from class java.util.AbstractCollection

addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, )]toArray, toString

Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List

addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, )]toArray

Field Detail

modCountprotected transient int modCount

The number of times this list has been structurally modified. Structural modifications are those that change the size of the list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results. 列表被结构性更改的次数。结构性更改指改变列表大小,或者其他方式使得遍历过程中 结果不正确。 This field is used by the iterator and list iterator implementation returned by the iterator and listIterator methods. If the value of this field changes unexpectedly, the iterator (or list iterator) will throw a ConcurrentModificationException in response to the next, remove, previous, set or add operations. This provides fail-fast behavior, rather than non-deterministic behavior in the face of concurrent modification during iteration. 该域由iterator和listIterator方法返回的迭代器和列表迭代器的实现使用。 如果该域的值被意外更改,迭代器(列表迭代器)将抛出ConcurrentModificationException 以响应next、remove、previous、set、或add操作。一旦在遍历过程中遇到同步修改时, 会导致fail-fast特性而不是非确定的行为。

Use of this field by subclasses is optional. If a subclass wishes to provide fail-fast iterators (and list iterators), then it merely has to increment this field in its add(int, Object) and remove(int) methods (and any other methods that it overrides that result in structural modifications to the list). A single call to add(int, Object) or remove(int) must add no more than one to this field, or the iterators (and list iterators) will throw bogus ConcurrentModificationExceptions. If an implementation does not wish to provide fail-fast iterators, this field may be ignored. 子类使用该域是可选的。如果子类希望提供fail-fast特性的迭代器(列表迭代器), 那么它必需在add(int, Object)和remove(int)方法(任何重写导致列表结构性更改的方法) 中增加该域值。add(int, Object)或remove(int)的单一调用会使该域值加1,或者抛出 假的ConcurrentModificationException。如果实现不希望提供fail-fast特性的迭代器,该域可以被忽略。

Constructor Detail

AbstractListprotected AbstractList()

Sole constructor. (For invocation by subclass constructors, typically implicit.) 唯一的构造函数。(通常由子类构造函数隐式调用)

Method Detail

addpublic boolean add(Object o)

Appends the specified element to the end of this List (optional operation). 向列表指定位置插入指定元素(可选操作)。 This implementation calls add(size(), o). 实现:调用add(size(), o)。

Note that this implementation throws an UnsupportedOperationException unless add(int, Object) is overridden. 注意除非add(int, Object)被重写,否则实现总是抛出UnsupportedOperationException。

Specified by: add in interface List Overrides: add in class AbstractCollectionParameters: o - element to be appended to this list. 要加入列表的元素。 Returns: true (as per the general contract of Collection.add). 根据Collection.add方法的一般约定返回true。 Throws: UnsupportedOperationException - if the add method is not supported by this Set. 如果列表不支持add方法时抛出。 ClassCastException - if the class of the specified element prevents it from being added to this set. 如果指定元素的类型阻止其加入列表时抛出。 IllegalArgumentException - some aspect of this element prevents it from being added to this collection. 如果该元素的某些方面不允许它加入当前集合则抛出。getpublic abstract Object get(int index)

Returns the element at the specified position in this list. 返回列表指定位置的元素。

Specified by: get in interface ListParameters: index - index of element to return. 返回元素的下标。 Returns: the element at the specified position in this list. 列表指定位置的元素。 Throws: IndexOutOfBoundsException - if the given index is out of range (index < 0 || index >= size()). 如果指定位置超出范围(index < 0 || index >= size())时抛出。setpublic Object set(int index,

Object element)

Replaces the element at the specified position in this list with the specified element (optional operation). 以指定元素替换列表指定位置的元素(可选操作)。 This implementation always throws an UnsupportedOperationException. 实现:总是抛出UnsupportedOperationException。

Specified by: set in interface ListParameters: index - index of element to replace. 要替换的元素下标。 element - element to be stored at the specified position. 存储在指定位置的元素。 Returns: the element previously at the specified position. 指定位置的原元素。 Throws: UnsupportedOperationException - if the set method is not supported by this List. 如果列表不支持set方法时抛出。 ClassCastException - if the class of the specified element prevents it from being added to this list. 如果指定元素的类型阻止其加入列表时抛出。 IllegalArgumentException - if some aspect of the specified element prevents it from being added to this list. 如果指定元素的某些方面不允许它加入当前列表则抛出。 IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()). 如果指定位置超出范围(index < 0 || index >= size())时抛出。addpublic void add(int index,

Object element)

Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). 向列表指定位置插入指定元素(可选操作)。当前位置的元素(若有)和所有后续元素右移(下标加1)。 This implementation always throws an UnsupportedOperationException. 实现:总是抛出UnsupportedOperationException。

Specified by: add in interface ListParameters: index - index at which the specified element is to be inserted. 要插入指定元素的下标。 element - element to be inserted. 要插入的元素。 Throws: UnsupportedOperationException - if the add method is not supported by this list. 如果列表不支持add方法时抛出。 ClassCastException - if the class of the specified element prevents it from being added to this list. 如果指定元素的类型阻止其加入列表时抛出。 IllegalArgumentException - if some aspect of the specified element prevents it from being added to this list. 如果指定元素的某些方面不允许它加入当前列表则抛出。 IndexOutOfBoundsException - index is out of range (index < 0 || index > size()). 位置超出范围(index < 0 || index > size())时抛出。removepublic Object remove(int index)

Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list. 删除列表中指定位置的元素(可选操作)。同时将所有后续元素左移(索引减1)。返回列表中被删除的元素。 This implementation always throws an UnsupportedOperationException. 实现:总是抛出UnsupportedOperationException。

Specified by: remove in interface ListParameters: index - the index of the element to remove. 要被删除的元素位置。 Returns: the element previously at the specified position. 指定位置前的元素。 Throws: UnsupportedOperationException - if the remove method is not supported by this list. 如果列表不支持remove方法时抛出。 IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()). 如果指定位置超出范围(index < 0 || index >= size())时抛出。indexOfpublic int indexOf(Object o)

Returns the index in this list of the first occurence of the specified element, or -1 if the list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index. 返回指定元素在列表中第一次出现的位置下标,如果不含该元素,返回-1。 正式表述为,如果存在那样的元素,使得(o==null ? get(i)==null : o.equals(get(i))), 那么返回最小的下标i,如果没有返回-1。 This implementation first gets a list iterator (with listIterator()). Then, it iterates over the list until the specified element is found or the end of the list is reached. 实现:首先利用listIterator()获得列表迭代器,然后,遍历列表直到找到指定元素或者到达列表末端。

Specified by: indexOf in interface ListParameters: o - element to search for. 要查找的元素。 Returns: the index in this List of the first occurence of the specified element, or -1 if the List does not contain this element. 指定元素在列表中第一次出现的位置,如果不含该元素,返回-1。lastIndexOfpublic int lastIndexOf(Object o)

Returns the index in this list of the last occurence of the specified element, or -1 if the list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index. 返回指定元素在列表中最后一次出现的位置下标,如果不含该元素,返回-1。 正式表述为,如果存在那样的元素,使得(o==null ? get(i)==null : o.equals(get(i))), 那么返回最大的下标i,如果没有返回-1。 This implementation first gets a list iterator that points to the end of the list (with listIterator(size())). Then, it iterates backwards over the list until the specified element is found, or the beginning of the list is reached. 实现:首先利用listIterator(size())获得列表迭代器,并指向列表末端,然后,由后向前遍历列表直到找到指定元素或者到达列表开头。

Specified by: lastIndexOf in interface ListParameters: o - element to search for. 要查找的元素。 Returns: the index in this list of the last occurence of the specified element, or -1 if the list does not contain this element. 指定元素在列表中最后一次出现的位置,如果不含该元素,返回-1。clearpublic void clear()

Removes all of the elements from this collection (optional operation). The collection will be empty after this call returns (unless it throws an exception). 从列表中删除所有元素(可选操作)。在调用返回后列表将为空(除非抛出异常)。 This implementation calls removeRange(0, size()). 实现:调用removeRange(0, size())。

Note that this implementation throws an UnsupportedOperationException unless remove(int index) or removeRange(int fromIndex, int toIndex) is overridden. 注意除非remove(int index)或者removeRange(int fromIndex, int toIndex)被重写,否则实现总是抛出UnsupportedOperationException。

Specified by: clear in interface List Overrides: clear in class AbstractCollectionThrows: UnsupportedOperationException - if the clear method is not supported by this Collection. 如果Collection不支持clear方法时抛出。addAllpublic boolean addAll(int index,

Collection c)

Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.) 向列表的指定位置插入指定集合的所有元素(可选操作)。当前位置的元素(若有) 和所有后续元素右移(下标加1)。列表中新元素的出现顺序为指定集合迭代器返回的 顺序。如果在该操作过程中指定集合被修改,操作行为无法确定。 (注意,这只有在指定集合为当前列表且非空的情况下才会发生。) This implementation gets an iterator over the specified collection and iterates over it, inserting the elements obtained from the iterator into this list at the appropriate position, one at a time, using add(int, Object). Many implementations will override this method for efficiency. 实现:获得指定集合的迭代器进行遍历,在合适位置向列表插入

Note that this implementation throws an UnsupportedOperationException unless add(int, Object) is overridden. 注意除非add(int, Object)被重写,否则实现总是抛出UnsupportedOperationException。

Specified by: addAll in interface ListParameters: index - index at which to insert the first element from the specified collection. 插入指定集合第一个元素的下标。 c - elements to be inserted into this List. 要插入列表的元素。 Returns: true if this list changed as a result of the call. 如果调用的结果改变了列表返回true。 Throws: UnsupportedOperationException - if the addAll method is not supported by this list. 如果列表不支持addAll方法时抛出。 ClassCastException - if the class of an element of the specified collection prevents it from being added to this List. 如果指定集合的某元素类型阻止其加入列表时抛出。 IllegalArgumentException - some aspect an element of the specified collection prevents it from being added to this List. 如果指定集合的某个元素的某些方面不允许它加入当前列表则抛出。 IndexOutOfBoundsException - index out of range (index < 0 || index > size()). 位置超出范围(index < 0 || index > size())时抛出。 NullPointerException - if the specified collection is null. 如果指定集合为null时抛出。iteratorpublic Iterator iterator()

Returns an iterator over the elements in this list in proper sequence. 以本来顺序返回列表元素的迭代器。 This implementation returns a straightforward implementation of the iterator interface, relying on the backing list's size(), get(int), and remove(int) methods. 实现:根据返回列表的size(),get(int)和remove(int)方法返回iterator接口的直接实现。

Note that the iterator returned by this method will throw an UnsupportedOperationException in response to its remove method unless the list's remove(int) method is overridden. 注意该实现返回的迭代器将抛出UnsupportedOperationException以响应 remove方法,除非列表的remove(int)方法被重写。

This implementation can be made to throw runtime exceptions in the face of concurrent modification, as described in the specification for the (protected) modCount field. 根据规范中对于保护域modCount的描述,该该实现在同步修改情况下将抛出运行时异常。

Specified by: iterator in interface List Specified by: iterator in class AbstractCollectionReturns: an iterator over the elements in this list in proper sequence. 以正常顺序返回列表元素的迭代器。 See Also: modCountlistIteratorpublic ListIterator listIterator()

Returns an iterator of the elements in this list (in proper sequence). This implementation returns listIterator(0). 以本来顺序返回列表元素的迭代器。实现返回listIterator(0)。

Specified by: listIterator in interface ListReturns: an iterator of the elements in this list (in proper sequence). 列表元素本来顺序的迭代器。 See Also: listIterator(int)listIteratorpublic ListIterator listIterator(int index)

Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to the next method. An initial call to the previous method would return the element with the specified index minus one. 从列表指定位置开始,以本来顺序返回列表元素的列表迭代器。指定的下标 表示第一次调用next方法返回的第一个元素。第一次调用previous方法返回 下标为指定下标减1的元素。 This implementation returns a straightforward implementation of the ListIterator interface that extends the implementation of the Iterator interface returned by the iterator() method. The ListIterator implementation relies on the backing list's get(int), set(int, Object), add(int, Object) and remove(int) methods. 实现:返回ListIterator接口的直接实现,继承由iterator()方法返回的Iterator接口实现。 ListIterator实现依赖于原列表的get(int)、set(int, Object)、add(int, Object)和 remove(int)方法。

Note that the list iterator returned by this implementation will throw an UnsupportedOperationException in response to its remove, set and add methods unless the list's remove(int), set(int, Object), and add(int, Object) methods are overridden. 注意该实现返回的列表迭代器将抛出UnsupportedOperationException以响应 remove、set和add方法,除非列表的remove(int)、set(int, Object)和add(int, Object) 方法被重写。

This implementation can be made to throw runtime exceptions in the face of concurrent modification, as described in the specification for the (protected) modCount field. 根据规范中对于保护域modCount的描述,该该实现在同步修改情况下将抛出运行时异常。

Specified by: listIterator in interface ListParameters: index - index of the first element to be returned from the list iterator (by a call to the next method). 列表迭代器调用next方法返回的第一个元素下标。 Returns: a list iterator of the elements in this list (in proper sequence), starting at the specified position in the list. 列表元素本来顺序的列表迭代器,从列表指定位置开始。 Throws: IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()). 如果指定位置超出范围(index < 0 || index > size())时抛出。 See Also: modCountsubListpublic List subList(int fromIndex,

int toIndex)

Returns a view of the portion of this list between fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list. 返回从fromIndex(含)到toIndex(不含)的部分列表视图。如果fromIndex和toIndex 相等,返回列表为空。返回列表由当前列表得出,因此返回列表的非结构性更改会影响到当前列表。 返回列表支持当前列表支持的所有可选操作。 This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by operating on a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list: 该方法克服了显式范围操作时需将列表转换成数组的弊端。 对于希望将列表用于范围操作的方法只需要传递给子列表视图代之整个列表。 例如,以下语法删除列表中某个范围的元素:

list.subList(from, to).clear();

Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList. 对于indexOf和lastIndexOf的用法相似,Collections类的所有算法 都可以在子列表中应用。 The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of the list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.) 如果返回列表通过某种方式使当前列表发生了结构性的改变,该方法返回的列表语义 将变得不能确定。(结构性的改变指改变列表的大小,或者在迭代过程中 以其它方式使得生成结果不正确。)

This implementation returns a list that subclasses AbstractList. The subclass stores, in private fields, the offset of the subList within the backing list, the size of the subList (which can change over its lifetime), and the expected modCount value of the backing list. There are two variants of the subclass, one of which implements RandomAccess. If this list implements RandomAccess the returned list will be an instance of the subclass that implements RandomAccess. 实现:返回AbstractList子类的列表。子类储存的私有域有:原列表的子列表偏移位置, 原表的modCount估计值。子类有两种,其中一种实现了RandomAccess。如果列表实现了 RandomAccess,那么返回列表将是实现RandomAccess的子类实例。

The subclass's set(int, Object), get(int), add(int, Object), remove(int), addAll(int, Collection) and removeRange(int, int) methods all delegate to the corresponding methods on the backing abstract list, after bounds-checking the index and adjusting for the offset. The addAll(Collection c) method merely returns addAll(size, c). 子类的set(int, Object)、get(int)、add(int, Object)、remove(int)、addAll(int, Collection) 和removeRange(int, int)在界限检查和调整偏移之后都代表着原抽象列表的对应方法。 addAll(Collection c)方法仅返回addAll(size, c)。

The listIterator(int) method returns a "wrapper object" over a list iterator on the backing list, which is created with the corresponding method on the backing list. The iterator method merely returns listIterator(), and the size method merely returns the subclass's size field. listIterator(int)方法返回一个原列表列表迭代器的包装对象,由原列表的相应方法创建。 iterator方法只不过返回listIterator(),size方法只是返回子类的size方法。

All methods first check to see if the actual modCount of the backing list is equal to its expected value, and throw a ConcurrentModificationException if it is not. 所有方法首先检查原列表实际的modCount是否和期望值相等,如果不相等的话抛出ConcurrentModificationException。

Specified by: subList in interface ListParameters: fromIndex - low endpoint (inclusive) of the subList. 子表的起始端(含)。 toIndex - high endpoint (exclusive) of the subList. 子表的结束端(不含)。 Returns: a view of the specified range within this list. 指定范围的列表视图。 Throws: IndexOutOfBoundsException - endpoint index value out of range (fromIndex < 0 || toIndex > size) 端点位置超出范围(fromIndex < 0 || toIndex > size())时抛出 IllegalArgumentException - endpoint indices out of order (fromIndex > toIndex) 端点下标无序(fromIndex > toIndex)equalspublic boolean equals(Object o)

Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order. 将指定对象和当前列表就相等性进行比较。只有指定对象也是一个列表, 两个列表有着相同大小,两个列表中所有对应元素都相等时返回true。 (如果(e1==null ? e2==null : e1.equals(e2)),那么两个元素e1和e2相等。) 换句话说,两个列表只有以相同顺序包含相同的元素,才被认为相等。 This implementation first checks if the specified object is this list. If so, it returns true; if not, it checks if the specified object is a list. If not, it returns false; if so, it iterates over both lists, comparing corresponding pairs of elements. If any comparison returns false, this method returns false. If either iterator runs out of elements before the other it returns false (as the lists are of unequal length); otherwise it returns true when the iterations complete. 实现:首先检查指定的对象是否为当前列表。如果是,返回true,不是检查指定对象是否是列表。 如果不是,返回false,如果是,对两个列表进行遍历,比较对应的元素对。 如果有比较返回false,方法返回false。如果其中一个的遍历元素结束而另一个没有返回false(由于列表不等长), 否则,遍历完成后返回true。

Specified by: equals in interface List Overrides: equals in class ObjectParameters: o - the object to be compared for equality with this list. 同当前列表比较相等性的对象。 Returns: true if the specified object is equal to this list. 如果指定的对象与当前列表相等,返回true。 See Also: Object.hashCode(), HashtablehashCodepublic int hashCode()

Returns the hash code value for this list. 返回列表的哈希码值。 This implementation uses exactly the code that is used to define the list hash function in the documentation for the List.hashCode method. 实现:使用了文档中对于List.hashCode方法定义的列表哈希功能代码。

Specified by: hashCode in interface List Overrides: hashCode in class ObjectReturns: the hash code value for this list. 列表的哈希码值。 See Also: Object.equals(java.lang.Object), HashtableremoveRangeprotected void removeRange(int fromIndex,

int toIndex)

Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the ArrayList by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation has no effect.) 删除从fromIndex(包括)到toIndex(不包括)位置间的列表所有元素。左移所有后续元素(减小索引)。调用将使ArrayList减少(toIndex - fromIndex)个元素。(如果toIndex==fromIndex,操作无效。) This method is called by the clear operation on this list and its subLists. Overriding this method to take advantage of the internals of the list implementation can substantially improve the performance of the clear operation on this list and its subLists. 方法由列表或其子列表的clear操作调用。重写该方法利用列表的内部实现可以本质上改善 列表和其子列表clear操作的性能。

This implementation gets a list iterator positioned before fromIndex, and repeatedly calls ListIterator.next followed by ListIterator.remove until the entire range has been removed. Note: if ListIterator.remove requires linear time, this implementation requires quadratic time. 实现:获取列表迭代器,定位于fromIndex之前,然后重复调用ListIterator.next和 ListIterator.remove,直到整个范围被删除。注意:如果ListIterator.remove 花销时间为线性,那么实现的花销时间以平方计。

Parameters: fromIndex - index of first element to be removed. 要删除的第一个元素下标。 toIndex - index after last element to be removed. 要删除的最后一个元素之后的下标。[/url][url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview

Package

Class

Use

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Std. Ed. v1.4.2

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature

For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有