📄 abstractlist.html
字号:
<DD>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 <tt>next</tt> method. An initial call to the <tt>previous</tt> method would return the element with the specified index minus one.<p> This implementation returns a straightforward implementation of the <tt>ListIterator</tt> interface that extends the implementation of the <tt>Iterator</tt> interface returned by the <tt>iterator()</tt> method. The <tt>ListIterator</tt> implementation relies on the backing list's <tt>get(int)</tt>, <tt>set(int, Object)</tt>, <tt>add(int, Object)</tt> and <tt>remove(int)</tt> methods.<p> Note that the list iterator returned by this implementation will throw an <tt>UnsupportedOperationException</tt> in response to its <tt>remove</tt>, <tt>set</tt> and <tt>add</tt> methods unless the list's <tt>remove(int)</tt>, <tt>set(int, Object)</tt>, and <tt>add(int, Object)</tt> methods are overridden.<p> This implementation can be made to throw runtime exceptions in the face of concurrent modification, as described in the specification for the (protected) <tt>modCount</tt> field.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#listIterator(int)">listIterator</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - index of the first element to be returned from the list iterator (by a call to the <tt>next</tt> method).<DT><B>Returns:</B><DD>a list iterator of the elements in this list (in proper sequence), starting at the specified position in the list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if the specified index is out of range (<tt>index < 0 || index > size()</tt>).<DT><B>See Also: </B><DD><A HREF="../../java/util/AbstractList.html#modCount"><CODE>modCount</CODE></A></DL></DD></DL><HR><A NAME="subList(int, int)"><!-- --></A><H3>subList</H3><PRE>public <A HREF="../../java/util/List.html">List</A> <B>subList</B>(int fromIndex, int toIndex)</PRE><DL><DD>Returns a view of the portion of this list between <tt>fromIndex</tt>, inclusive, and <tt>toIndex</tt>, exclusive. (If <tt>fromIndex</tt> and <tt>toIndex</tt> 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.<p> 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: <pre> list.subList(from, to).clear(); </pre> Similar idioms may be constructed for <tt>indexOf</tt> and <tt>lastIndexOf</tt>, and all of the algorithms in the <tt>Collections</tt> class can be applied to a subList.<p> The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is <i>structurally modified</i> 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.)<p> This implementation returns a list that subclasses <tt>AbstractList</tt>. 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 <tt>modCount</tt> value of the backing list.<p> The subclass's <tt>set(int, Object)</tt>, <tt>get(int)</tt>, <tt>add(int, Object)</tt>, <tt>remove(int)</tt>, <tt>addAll(int, Collection)</tt> and <tt>removeRange(int, int)</tt> methods all delegate to the corresponding methods on the backing abstract list, after bounds-checking the index and adjusting for the offset. The <tt>addAll(Collection c)</tt> method merely returns <tt>addAll(size, c)</tt>.<p> The <tt>listIterator(int)</tt> 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 <tt>iterator</tt> method merely returns <tt>listIterator()</tt>, and the <tt>size</tt> method merely returns the subclass's <tt>size</tt> field.<p> All methods first check to see if the actual <tt>modCount</tt> of the backing list is equal to its expected value, and throw a <tt>ConcurrentModificationException</tt> if it is not.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#subList(int, int)">subList</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>fromIndex</CODE> - low endpoint (inclusive) of the subList.<DD><CODE>toIndex</CODE> - high endpoint (exclusive) of the subList.<DT><B>Returns:</B><DD>a view of the specified range within this list.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - endpoint index value out of range <tt>(fromIndex < 0 || toIndex > size)</tt><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - endpoint indices out of order <tt>(fromIndex > toIndex)</tt></DL></DD></DL><HR><A NAME="equals(java.lang.Object)"><!-- --></A><H3>equals</H3><PRE>public boolean <B>equals</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Compares the specified object with this list for equality. Returns <tt>true</tt> 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 <i>equal</i>. (Two elements <tt>e1</tt> and <tt>e2</tt> are <i>equal</i> if <tt>(e1==null ? e2==null : e1.equals(e2))</tt>.) In other words, two lists are defined to be equal if they contain the same elements in the same order.<p> This implementation first checks if the specified object is this list. If so, it returns <tt>true</tt>; if not, it checks if the specified object is a list. If not, it returns <tt>false</tt>; if so, it iterates over both lists, comparing corresponding pairs of elements. If any comparison returns <tt>false</tt>, this method returns <tt>false</tt>. If either iterator runs out of elements before the other it returns <tt>false</tt> (as the lists are of unequal length); otherwise it returns <tt>true</tt> when the iterations complete.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#equals(java.lang.Object)">equals</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - the object to be compared for equality with this list.<DT><B>Returns:</B><DD><tt>true</tt> if the specified object is equal to this list.</DL></DD></DL><HR><A NAME="hashCode()"><!-- --></A><H3>hashCode</H3><PRE>public int <B>hashCode</B>()</PRE><DL><DD>Returns the hash code value for this list. <p> This implementation uses exactly the code that is used to define the list hash function in the documentation for the <tt>List.hashCode</tt> method.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#hashCode()">hashCode</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#hashCode()">hashCode</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the hash code value for this list.</DL></DD></DL><HR><A NAME="removeRange(int, int)"><!-- --></A><H3>removeRange</H3><PRE>protected void <B>removeRange</B>(int fromIndex, int toIndex)</PRE><DL><DD>Removes from this list all of the elements whose index is between <tt>fromIndex</tt>, inclusive, and <tt>toIndex</tt>, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the ArrayList by <tt>(toIndex - fromIndex)</tt> elements. (If <tt>toIndex==fromIndex</tt>, this operation has no effect.)<p> This method is called by the <tt>clear</tt> operation on this list and its subLists. Overriding this method to take advantage of the internals of the list implementation can <i>substantially</i> improve the performance of the <tt>clear</tt> operation on this list and its subLists.<p> This implementation gets a list iterator positioned before <tt>fromIndex</tt>, and repeatedly calls <tt>ListIterator.next</tt> followed by <tt>ListIterator.remove</tt> until the entire range has been removed. <b>Note: if <tt>ListIterator.remove</tt> requires linear time, this implementation requires quadratic time.</b><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>fromIndex</CODE> - index of first element to be removed.<DD><CODE>toIndex</CODE> - index after last element to be removed.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/AbstractList.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/util/AbstractCollection.html"><B>PREV CLASS</B></A> <A HREF="../../java/util/AbstractMap.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="AbstractList.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -