📄 vector.html
字号:
of this vector.</DL></DD></DL><HR><A NAME="size()"><!-- --></A><H3>size</H3><PRE>public int <B>size</B>()</PRE><DL><DD>Returns the number of components in this vector.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#size()">size</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#size()">size</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of components in this vector.</DL></DD></DL><HR><A NAME="isEmpty()"><!-- --></A><H3>isEmpty</H3><PRE>public boolean <B>isEmpty</B>()</PRE><DL><DD>Tests if this vector has no components.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#isEmpty()">isEmpty</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#isEmpty()">isEmpty</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if and only if this vector has no components, that is, its size is zero; <code>false</code> otherwise.</DL></DD></DL><HR><A NAME="elements()"><!-- --></A><H3>elements</H3><PRE>public <A HREF="../../java/util/Enumeration.html">Enumeration</A> <B>elements</B>()</PRE><DL><DD>Returns an enumeration of the components of this vector. The returned <tt>Enumeration</tt> object will generate all items in this vector. The first item generated is the item at index <tt>0</tt>, then the item at index <tt>1</tt>, and so on.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>an enumeration of the components of this vector.<DT><B>See Also: </B><DD><A HREF="../../java/util/Enumeration.html"><CODE>Enumeration</CODE></A>, <A HREF="../../java/util/Iterator.html"><CODE>Iterator</CODE></A></DL></DD></DL><HR><A NAME="contains(java.lang.Object)"><!-- --></A><H3>contains</H3><PRE>public boolean <B>contains</B>(<A HREF="../../java/lang/Object.html">Object</A> elem)</PRE><DL><DD>Tests if the specified object is a component in this vector.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#contains(java.lang.Object)">contains</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractCollection.html#contains(java.lang.Object)">contains</A></CODE> in class <CODE><A HREF="../../java/util/AbstractCollection.html">AbstractCollection</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>elem</CODE> - an object.<DT><B>Returns:</B><DD><code>true</code> if and only if the specified object is the same as a component in this vector, as determined by the <tt>equals</tt> method; <code>false</code> otherwise.</DL></DD></DL><HR><A NAME="indexOf(java.lang.Object)"><!-- --></A><H3>indexOf</H3><PRE>public int <B>indexOf</B>(<A HREF="../../java/lang/Object.html">Object</A> elem)</PRE><DL><DD>Searches for the first occurence of the given argument, testing for equality using the <code>equals</code> method.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#indexOf(java.lang.Object)">indexOf</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#indexOf(java.lang.Object)">indexOf</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>elem</CODE> - an object.<DT><B>Returns:</B><DD>the index of the first occurrence of the argument in this vector, that is, the smallest value <tt>k</tt> such that <tt>elem.equals(elementData[k])</tt> is <tt>true</tt>; returns <code>-1</code> if the object is not found.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Object.html#equals(java.lang.Object)"><CODE>Object.equals(Object)</CODE></A></DL></DD></DL><HR><A NAME="indexOf(java.lang.Object, int)"><!-- --></A><H3>indexOf</H3><PRE>public int <B>indexOf</B>(<A HREF="../../java/lang/Object.html">Object</A> elem, int index)</PRE><DL><DD>Searches for the first occurence of the given argument, beginning the search at <code>index</code>, and testing for equality using the <code>equals</code> method.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>elem</CODE> - an object.<DD><CODE>index</CODE> - the non-negative index to start searching from.<DT><B>Returns:</B><DD>the index of the first occurrence of the object argument in this vector at position <code>index</code> or later in the vector, that is, the smallest value <tt>k</tt> such that <tt>elem.equals(elementData[k]) && (k >= index)</tt> is <tt>true</tt>; returns <code>-1</code> if the object is not found. (Returns <code>-1</code> if <tt>index</tt> >= the current size of this <tt>Vector</tt>.)<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <tt>index</tt> is negative.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Object.html#equals(java.lang.Object)"><CODE>Object.equals(Object)</CODE></A></DL></DD></DL><HR><A NAME="lastIndexOf(java.lang.Object)"><!-- --></A><H3>lastIndexOf</H3><PRE>public int <B>lastIndexOf</B>(<A HREF="../../java/lang/Object.html">Object</A> elem)</PRE><DL><DD>Returns the index of the last occurrence of the specified object in this vector.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/util/List.html#lastIndexOf(java.lang.Object)">lastIndexOf</A></CODE> in interface <CODE><A HREF="../../java/util/List.html">List</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/util/AbstractList.html#lastIndexOf(java.lang.Object)">lastIndexOf</A></CODE> in class <CODE><A HREF="../../java/util/AbstractList.html">AbstractList</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>elem</CODE> - the desired component.<DT><B>Returns:</B><DD>the index of the last occurrence of the specified object in this vector, that is, the largest value <tt>k</tt> such that <tt>elem.equals(elementData[k])</tt> is <tt>true</tt>; returns <code>-1</code> if the object is not found.</DL></DD></DL><HR><A NAME="lastIndexOf(java.lang.Object, int)"><!-- --></A><H3>lastIndexOf</H3><PRE>public int <B>lastIndexOf</B>(<A HREF="../../java/lang/Object.html">Object</A> elem, int index)</PRE><DL><DD>Searches backwards for the specified object, starting from the specified index, and returns an index to it.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>elem</CODE> - the desired component.<DD><CODE>index</CODE> - the index to start searching from.<DT><B>Returns:</B><DD>the index of the last occurrence of the specified object in this vector at position less than or equal to <code>index</code> in the vector, that is, the largest value <tt>k</tt> such that <tt>elem.equals(elementData[k]) && (k <= index)</tt> is <tt>true</tt>; <code>-1</code> if the object is not found. (Returns <code>-1</code> if <tt>index</tt> is negative.)<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <tt>index</tt> is greater than or equal to the current size of this vector.</DL></DD></DL><HR><A NAME="elementAt(int)"><!-- --></A><H3>elementAt</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>elementAt</B>(int index)</PRE><DL><DD>Returns the component at the specified index.<p> This method is identical in functionality to the get method (which is part of the List interface).<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - an index into this vector.<DT><B>Returns:</B><DD>the component at the specified index.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if the <tt>index</tt> is negative or not less than the current size of this <tt>Vector</tt> object. given.<DT><B>See Also: </B><DD><A HREF="../../java/util/Vector.html#get(int)"><CODE>get(int)</CODE></A>, <A HREF="../../java/util/List.html"><CODE>List</CODE></A></DL></DD></DL><HR><A NAME="firstElement()"><!-- --></A><H3>firstElement</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>firstElement</B>()</PRE><DL><DD>Returns the first component (the item at index <tt>0</tt>) of this vector.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the first component of this vector.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/util/NoSuchElementException.html">NoSuchElementException</A></CODE> - if this vector has no components.</DL></DD></DL><HR><A NAME="lastElement()"><!-- --></A><H3>lastElement</H3><PRE>public <A HREF="../../java/lang/Object.html">Object</A> <B>lastElement</B>()</PRE><DL><DD>Returns the last component of the vector.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the last component of the vector, i.e., the component at index <code>size() - 1</code>.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/util/NoSuchElementException.html">NoSuchElementException</A></CODE> - if this vector is empty.</DL></DD></DL><HR><A NAME="setElementAt(java.lang.Object, int)"><!-- --></A><H3>setElementAt</H3><PRE>public void <B>setElementAt</B>(<A HREF="../../java/lang/Object.html">Object</A> obj, int index)</PRE><DL><DD>Sets the component at the specified <code>index</code> of this vector to be the specified object. The previous component at that position is discarded.<p> The index must be a value greater than or equal to <code>0</code> and less than the current size of the vector. <p> This method is identical in functionality to the set method (which is part of the List interface). Note that the set method reverses the order of the parameters, to more closely match array usage. Note also that the set method returns the old value that was stored at the specified position.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>obj</CODE> - what the component is to be set to.<DD><CODE>index</CODE> - the specified index.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if the index was invalid.<DT><B>See Also: </B><DD><A HREF="../../java/util/Vector.html#size()"><CODE>size()</CODE></A>, <A HREF="../../java/util/List.html"><CODE>List</CODE></A>, <A HREF="../../java/util/Vector.html#set(int, java.lang.Object)"><CODE>set(int, java.lang.Object)</CODE></A></DL></DD></DL><HR><A NAME="removeElementAt(int)"><!-- --></A><H3>removeElementAt</H3><PRE>public void <B>removeElementAt</B>(int index)</PRE><DL><DD>Deletes the component at the specified index. Each component in this vector with an index greater or equal to the specified <code>index</code> is shifted downward to have an index one smaller than the value it had previously. The size of this vector is decreased by <tt>1</tt>.<p> The index must be a value greater than or equal to <code>0</code> and less than the current size of the vector. <p> This method is identical in functionality to the remove method (which is part of the List interface). Note that the remove method returns the old value that was stored at the specified position.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>index</CODE> - the index of the object to remove.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if the index was invalid.<DT><B>See Also: </B><DD><A HREF="../../java/util/Vector.html#size()"><CODE>size()</CODE></A>, <A HREF="../../java/util/Vector.html#remove(int)"><CODE>remove(int)</CODE></A>, <A HREF="../../java/util/List.html"><CODE>List</CODE></A></DL></DD></DL><HR><A NAME="insertElementAt(java.lang.Object, int)"><!-- --></A><H3>insertElementAt</H3><PRE>public void <B>insertElementAt</B>(<A HREF="../../java/lang/Object.html">Object</A> obj, int index)</PRE><DL><DD>Inserts the specified object as a component in this vector at the specified <code>index</code>. Each component in this vector with an index greater or equal to the specified <code>index</code> is shifted upward to have an index one greater than the value it had previously. <p> The index must be a value greater than or equal to <code>0</code> and less than or equal to the current size of the vector. (If the index is equal to the current size of the vector, the new element is appended to the Vector.)<p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -