- 浏览: 16029365 次
- 性别:
- 来自: 济南
最新评论
-
wu1236:
ef0793cd94337324b6fefc4c9474af5 ...
Android ApiDemos示例解析(87):Media->MediaPlayer -
77219634:
0127bf2236bee4dd1f632ce430f1af1 ...
本博客文章都为转载,没有任何版权! -
77219634:
0127bf2236bee4dd1f632ce430f1af1 ...
VPLEX - EMC的RAC -
77219634:
0127bf2236bee4dd1f632ce430f1af1 ...
qTip2 Show -
77219634:
0127bf2236bee4dd1f632ce430f1af1 ...
SecureCRT中文乱码、复制粘贴乱码解决办法(修改版)
<!-- -->
|
JavaTM2Platform Std.Ed. v1.4.2 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES <!-- if(window==top) { document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> All Classes <noscript></noscript> | ||||||||
SUMMARY:NESTED|FIELD|CONSTR|METHOD | DETAIL:FIELD|CONSTR|METHOD |
<!-- ======== START OF CLASS DATA ======== -->
java.util
Class Vector
java.lang.Object java.util.AbstractCollection java.util.AbstractList java.util.Vector
The Vector
class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector
can grow or shrink as needed to accommodate adding and removing items after the Vector
has been created. Vector类实现了一个可增长对象数组。和数组一样,它所包含的成员可以使用整型 下标访问。然而,Vector可以创建后在添加或删除项有需要时增加或减小大小。
Each vector tries to optimize storage management by maintaining a capacity
and a capacityIncrement
. The capacity
is always at least as large as the vector size; it is usually larger because as components are added to the vector, the vector's storage increases in chunks the size of capacityIncrement
. An application can increase the capacity of a vector before inserting a large number of components; this reduces the amount of incremental reallocation. 每一个vector都试图通过对capacity和capacityIncrement的维护来优化存储管理。 capacity至少应和vector的大小一样,通常情况下要更大,因为成员被加入vector 时,vector的容量每次会增加capacityIncrement的大小。应用程序可以在插入 大量成员之前增加vector的大小,这将减少增长重分配的次数。
As of the Java 2 platform v1.2, this class has been retrofitted to implement List, so that it becomes a part of Java's collection framework. Unlike the new collection implementations, Vector is synchronized. 从Java 2平台1.2以来,该类已作更改以实现List,因此它成了Java集合框架的一部分。 和其他新的集合实现不同,Vector是同步化的。
The Iterators returned by Vector's iterator and listIterator methods are fail-fast: if the Vector is structurally modified at any time after the Iterator is created, in any way except through the Iterator's own remove or add methods, the Iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the Iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future. The Enumerations returned by Vector's elements method are not fail-fast. 由Vector的的iterator和listIterator方法返回的Iterator也具有fail-fast特性:即如果Vector在Iterator创建后使用除Iterator自身的remove或add方法以外的方式使其有了结构性更改,Iterator将抛出ConcurrentModificationException。因此,遇到同步修改时,Iterator会立即失败,宁可不冒未来某一时刻不能确定的行为风险。 Vector的elements方法返回的Enumeration不具有fail-fast特性。
Note that the fail-fast behavior of an iterator cannot be guaranteed as it is, generally speaking, impossible to make any hard guarantees in the presence of unsynchronized concurrent modification. Fail-fast iterators throw ConcurrentModificationException on a best-effort basis. Therefore, it would be wrong to write a program that depended on this exception for its correctness: the fail-fast behavior of iterators should be used only to detect bugs. 注意迭代器的fail-fast特性不能保证,正如在非同步化修改中做保证也是不可能的。 具有fail-fast特性的迭代器会基于最有效原则抛出 ConcurrentModificationException, 因此写的程序依赖于该异常来纠正是错误的:迭代器的fail-fast特性应该只用来调试bug。
This class is a member of the Java Collections Framework. 该接口是Java集合框架成员之一。
Collection
, List
, ArrayList
, LinkedList
, Serialized Form
<!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- -->
Field Summary | |
protected int |
capacityIncrement The amount by which the capacity of the vector is automatically incremented when its size becomes greater than its capacity. 当vector的大小超出它的容量时,容量的自动增加量。 |
protected int |
elementCount The number of valid components in this Vector object. Vector对象的有效成员数。 |
protected Object[] |
elementData The array buffer into which the components of the vector are stored. 存储vector成员的数组缓冲。 |
Fields inherited from class java.util.AbstractList |
modCount |
Constructor Summary |
Vector() Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero. 构造一个空vector,内部数据数组大小为10,标准容量增长量为0。 |
Vector(Collectionc) Constructs a vector containing the elements of the specified collection, in the order they are returned by the collection's iterator. 构造一个vector,包含指定集合的元素,顺序为集合迭代器的返回顺序。 |
Vector(intinitialCapacity) Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero. 构造一个空vector,指定初始容量,标准容量增长量为0。 |
Vector(intinitialCapacity, intcapacityIncrement) Constructs an empty vector with the specified initial capacity and capacity increment. 构造一个空vector,指定初始容量和标准容量增长量。 |
Method Summary | |
void |
add(intindex, Objectelement) Inserts the specified element at the specified position in this Vector. 向Vector指定位置插入指定元素。 |
boolean |
add(Objecto) Appends the specified element to the end of this Vector. 向Vector末尾添加指定元素。 |
boolean |
addAll(Collectionc) Appends all of the elements in the specified Collection to the end of this Vector, in the order that they are returned by the specified Collection's Iterator. 向Vector尾部追加指定集合的所有元素,以指定集合的Iterator返回顺序为序。 |
boolean |
addAll(intindex, Collectionc) Inserts all of the elements in in the specified Collection into this Vector at the specified position. 向Vector指定位置插入指定Collection的所有元素。 |
void |
addElement(Objectobj) Adds the specified component to the end of this vector, increasing its size by one. 向Vector末尾添加指定元素,大小加1。 |
int |
capacity() Returns the current capacity of this vector. 返回当前vector的容量。 |
void |
clear() Removes all of the elements from this Vector. 从Vector中删除所有元素。 |
Object |
clone() Returns a clone of this vector. 返回vector的克隆。 |
boolean |
contains(Objectelem) Tests if the specified object is a component in this vector. 测试指定对象是否是vector的成员。 |
boolean |
containsAll(Collectionc) Returns true if this Vector contains all of the elements in the specified Collection. 如果Vector包含指定集合的所有元素,返回true。 |
void |
copyInto(Object[]anArray) Copies the components of this vector into the specified array. 向指定数组拷贝vector的成员。 |
Object |
elementAt(intindex) Returns the component at the specified index. 返回指定下标的成员。 |
Enumeration |
elements() Returns an enumeration of the components of this vector. 返回vector的成员枚举。 |
void |
ensureCapacity(intminCapacity) Increases the capacity of this vector, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument. 增加vector的容量,确保能容纳由minCapacity参数指定的成员数量。 |
boolean |
equals(Objecto) Compares the specified Object with this Vector for equality. 将指定对象和当前Vector比较相等性。 |
Object |
firstElement() Returns the first component (the item at index 0) of this vector. 返回vector的第一个成员(下标为0)。 |
Object |
get(intindex) Returns the element at the specified position in this Vector. 返回Vector中指定位置的元素。 |
int |
hashCode() Returns the hash code value for this Vector. 返回Vector的哈希码值。 |
int |
indexOf(Objectelem) Searches for the first occurence of the given argument, testing for equality using the equals method. 查找指定参数第一次出现的位置,使用equals方法测试相等性。
|
int |
indexOf(Objectelem, intindex) Searches for the first occurence of the given argument, beginning the search at index , and testing for equality using the equals method. 由下标index开始查找指定参数第一次出现的位置,使用equals方法测试相等性。
|
void |
insertElementAt(Objectobj, intindex) Inserts the specified object as a component in this vector at the specified index . 以指定对象为成员插入vector指定下标位置处。
|
boolean |
isEmpty() Tests if this vector has no components. 测试vector是否没有成员。 |
Object |
lastElement() Returns the last component of the vector. 返回vector的最后一个成员。 |
int |
lastIndexOf(Objectelem) Returns the index of the last occurrence of the specified object in this vector. 返回vector中指定对象最后一次出现的下标。 |
int |
lastIndexOf(Objectelem, intindex) Searches backwards for the specified object, starting from the specified index, and returns an index to it. 由指定下标开始,向后查找指定对象,返回对象的下标。 |
Object |
remove(intindex) Removes the element at the specified position in this Vector. 从Vector中删除指定位置的元素。 |
boolean |
remove(Objecto) Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged. 从Vector中删除第一个出现的指定元素。如果不含该元素,Vector不变。 |
boolean |
removeAll(Collectionc) Removes from this Vector all of its elements that are contained in the specified Collection. 从Vector中删除指定集合包含的所有元素。 |
void |
removeAllElements() Removes all components from this vector and sets its size to zero. 删除vector的所有成员,大小设为0。 |
boolean |
removeElement(Objectobj) Removes the first (lowest-indexed) occurrence of the argument from this vector. 从vector中删除第一个(下标最小)出现的参数。 |
void |
removeElementAt(intindex) Deletes the component at the specified index. 删除指定下标的成员。 |
protected void |
removeRange(intfromIndex, inttoIndex) Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. 从List中删除下标在fromIndex(含)和toIndex(不含)之间的所有元素。 |
boolean |
retainAll(Collectionc) Retains only the elements in this Vector that are contained in the specified Collection. 使Vector只保留指定集合中所含的元素。 |
Object |
set(intindex, Objectelement) Replaces the element at the specified position in this Vector with the specified element. 用指定元素替换Vector指定位置的元素。 |
void |
setElementAt(Objectobj, intindex) Sets the component at the specified index of this vector to be the specified object. 将vector指定下标的成员设为指定对象。
|
void |
setSize(intnewSize) Sets the size of this vector. 设置vector的大小。 |
int |
size() Returns the number of components in this vector. 返回vector的成员数量。 |
List |
subList(intfromIndex, inttoIndex) Returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive. 返回List中下标在fromIndex(含)和toIndex(不含)之间的元素视图。 |
Object[] |
toArray() Returns an array containing all of the elements in this Vector in the correct order. 返回一个数组,以正确的顺序包含Vector的所有元素。 |
Object[] |
toArray(Object[]a) Returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array. 返回一个数组,以正确的顺序包含Vector的所有元素,返回数组的运行时类型为指定数组的类型。 |
String |
toString() Returns a string representation of this Vector, containing the String representation of each element. 返回Vector的字符串形式,包含每一个元素的字符串形式。 |
void |
trimToSize() Trims the capacity of this vector to be the vector's current size. 将vector的容量调整为vector的当前大小。 |
Methods inherited from class java.util.AbstractList |
iterator, listIterator, listIterator |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
iterator, listIterator, listIterator |
<!-- ============ FIELD DETAIL =========== --><!-- -->
Field Detail |
elementData
protected Object[] elementData
Any array elements following the last element in the Vector are null. 紧随Vector最后一个元素的任意数组元素为null。
<!-- -->
elementCount
protected int elementCount
<!-- -->
capacityIncrement
protected int capacityIncrement
Constructor Detail |
Vector
public Vector(intinitialCapacity, intcapacityIncrement)
initialCapacity
- the initial capacity of the vector. vector的初始容量。 capacityIncrement
- the amount by which the capacity is increased when the vector overflows. 当vector填满时增加的容量值。 IllegalArgumentException
- if the specified initial capacity is negative 如果指定初始容量为负时抛出
<!-- -->
Vector
public Vector(intinitialCapacity)
initialCapacity
- the initial capacity of the vector. vector的初始容量。 IllegalArgumentException
- if the specified initial capacity is negative 如果指定初始容量为负时抛出
<!-- -->
Vector
public Vector()
<!-- -->
Vector
public Vector(Collectionc)
c
- the collection whose elements are to be placed into this vector. 被放入vector的元素集合。 NullPointerException
- if the specified collection is null.] 如果指定集合为null时抛出。
Method Detail |
copyInto
public void copyInto(Object[]anArray)
anArray
- the array into which the components get copied. 成员被拷贝至的数组。 NullPointerException
- if the given array is null. 如果指定数组为null时抛出。
<!-- -->
trimToSize
public void trimToSize()
<!-- -->
ensureCapacity
public void ensureCapacity(intminCapacity)
If the current capacity of this vector is less than minCapacity, then its capacity is increased by replacing its internal data array, kept in the field elementData, with a larger one. The size of the new data array will be the old size plus capacityIncrement, unless the value of capacityIncrement is less than or equal to zero, in which case the new capacity will be twice the old capacity; but if this new size is still smaller than minCapacity, then the new capacity will be minCapacity. 如果vector的当前容量小于minCapacity,那么通过替换其内部数据数组(由elementData 维护)来增加其容量。数据数组的新的大小将是在旧的大小上加上capacityIncrement, 除非capacityIncrement值小于等于0,这种情况下新的容量将是旧容量的两倍, 但是如果新的大小仍然小于minCapacity,那么新的容量将是minCapacity。
minCapacity
- the desired minimum capacity. 期望的最小容量。<!-- -->
setSize
public void setSize(intnewSize)
null
items are added to the end of the vector. If the new size is less than the current size, all components at index newSize
and greater are discarded. 设置vector的大小。如果新的大小大于当前大小,那么向vector尾部添加新的null项。 如果新的大小小于当前大小,所有位于下标newSize和大于该下标的成员全都被丢弃。
newSize
- the new size of this vector. vector新的大小。 ArrayIndexOutOfBoundsException
- if new size is negative.
<!-- -->
capacity
public int capacity()
<!-- -->
size
public int size()
size
in interface List
size
in class AbstractCollection
<!-- -->
isEmpty
public boolean isEmpty()
isEmpty
in interface List
isEmpty
in class AbstractCollection
true
if and only if this vector has no components, that is, its size is zero; false
otherwise. 只有当vector不含元素,即大小为0时,返回true;否则为false。<!-- -->
elements
public Enumeration elements()
Enumeration
, Iterator
<!-- -->
contains
public boolean contains(Objectelem)
contains
in interface List
contains
in class AbstractCollection
elem
- an object. 一个对象。 true
if and only if the specified object is the same as a component in this vector, as determined by the equals method; false
otherwise. 只有当指定的对象和vector的一个成员相同(由equals方法确定)时返回true,否则返回false。<!-- -->
indexOf
public int indexOf(Objectelem)
equals
method. 查找指定参数第一次出现的位置,使用equals方法测试相等性。
indexOf
in interface List
indexOf
in class AbstractList
elem
- an object. 对象。 -1
if the object is not found. 参数在vector中第一次出现的位置,即使得elem.equals(elementData[k])为true的最小值k, 如果找不到该对象,返回-1。 Object.equals(Object)
<!-- -->
indexOf
public int indexOf(Objectelem, intindex)
index
, and testing for equality using the equals
method. 由下标index开始查找指定参数第一次出现的位置,使用equals方法测试相等性。
elem
- an object. index
- the non-negative index to start searching from. index
or later in the vector, that is, the smallest value k such that elem.equals(elementData[k]) && (k >= index) is true; returns -1
if the object is not found. (Returns -1
if index >= the current size of this Vector.) 对象参数在vector中从位置index开始第一次出现的位置,即使得elem.equals(elementData[k]) && (k >= index)为true的最小值k,如果找不到该对象,返回-1。 (如果index >= Vector的当前大小,返回-1。) IndexOutOfBoundsException
- if index is negative. 如果index为负时抛出。
Object.equals(Object)
<!-- -->
lastIndexOf
public int lastIndexOf(Objectelem)
lastIndexOf
in interface List
lastIndexOf
in class AbstractList
elem
- the desired component. 期望成员。 -1
if the object is not found. 指定对象在vector中最后一次出现的位置,即使得elem.equals(elementData[k])为true 的最大值k,如果找不到该对象,返回-1。<!-- -->
lastIndexOf
public int lastIndexOf(Objectelem, intindex)
elem
- the desired component. 期望成员。 index
- the index to start searching from. 起始查找的下标。 index
in the vector, that is, the largest value k such that elem.equals(elementData[k]) && (k <= index) is true; -1
if the object is not found. (Returns -1
if index is negative.) 对象参数在vector中从位置index开始最后一次出现的位置,即使得 elem.equals(elementData[k]) && (k <= index)为true的最大值k, 如果找不到该对象,返回-1。(如果index为负时,返回-1。) IndexOutOfBoundsException
- if index is greater than or equal to the current size of this vector. 如果index大于等于vector的当前大小时抛出。
<!-- -->
elementAt
public Object elementAt(intindex)
This method is identical in functionality to the get method (which is part of the List interface). 该方法和get方法(List接口的一部分)功能上一致。
index
- an index into this vector. vector的一个下标。 ArrayIndexOutOfBoundsException
- if the index is negative or not less than the current size of this Vector object. 如果下标为负或者不小于当前Vector对象的大小时抛出。 given.
get(int)
, List
<!-- -->
firstElement
public Object firstElement()
NoSuchElementException
- if this vector has no components. 如果vector没有成员时抛出。
<!-- -->
lastElement
public Object lastElement()
size()-1
. vector的最后一个成员,即下标为size()-1的成员。 NoSuchElementException
- if this vector is empty. 如果vector为空时抛出。
<!-- -->
setElementAt
public void setElementAt(Objectobj, intindex)
index
of this vector to be the specified object. The previous component at that position is discarded. 将vector指定下标的成员设为指定对象。该位置的原成员被丢弃。 The index must be a value greater than or equal to 0
and less than the current size of the vector. index应该大于等于0,而小于等于vector的当前大小。
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. 该方法和set方法(List接口的一部分)功能上一致。注意:set方法颠倒了参数的顺序,更符合数组的用法。 set方法返回指定位置存储的旧值。
obj
- what the component is to be set to. 要被设置的成员。 index
- the specified index. 指定的下标。 ArrayIndexOutOfBoundsException
- if the index was invalid. 如果index无效时抛出。
size()
, List
, set(int, java.lang.Object)
<!-- -->
removeElementAt
public void removeElementAt(intindex)
index
is shifted downward to have an index one smaller than the value it had previously. The size of this vector is decreased by 1. 删除指定下标的成员。vector中每一个下标大于指定index的成员均左移,下标值减1。 vector的大小减1。 The index must be a value greater than or equal to 0
and less than the current size of the vector. index应该大于等于0,而小于等于vector的当前大小。
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. 该方法和remove方法(List接口的一部分)功能上一致。注意:remove方法返回指定位置存储的旧值。
index
- the index of the object to remove. 要删除对象的下标。 ArrayIndexOutOfBoundsException
- if the index was invalid.
size()
, remove(int)
, List
<!-- -->
insertElementAt
public void insertElementAt(Objectobj, intinde发表评论
相关推荐
NULL 博文链接:https://corrinejtt.iteye.com/blog/859792
Java提供日期(Data)类、日历(Calendar)类,随机数(Random)类,堆栈(Stack)、向量(Vector) 、位集合(Bitset)以及哈希表(Hashtable)等类来表示相应的数据结构
运用下列类进行JAVA编程: Date Calendar Random 使用 Collection 接口及其实现类 ArrayList LinkedList 使用 HashMap 使用Vector 等方法的使用
介绍Java的实用工具类库java.util包。在这个包中,Java提供了一些实用的方法和数据结构。例如,Java提供日期(Data)类、日历(Calendar)类来产生和获取日期及时间,提供随机数(Random)类产生各种类型的随机数,还提供...
例如,Java提供日期(Data)类、日历(Calendar)类来产生和获取日期及时间,提供随机数(Random)类产生各种类型的随机数,还提供了堆栈(Stack)、向量(Vector)、位集合(Bitset)以及哈希表(Hashtable)等类来表示相应的数据...
韩顺平老师讲的坦克大战源代码 坦克大战源码 根据韩顺平老师视频所作 /**坦克大战4.0 * 防重叠 ...import java.util.Vector; public class MyTankGame5 extends JFrame implements ActionListener{
import java.util.ArrayList; import java.util.List; import java.util.UUID; /** * @author: Raicho * @Description: * @program: mianshi * @create: 2020-07-17 15:32 **/ public class ...
import java.util.Vector; import java.sql.DriverManager; import java.sql.SQLException; public class DBOperation { private Connection con; public Connection getConnection() { try { Class.for...
import java.util.Vector; public class TelephoneNum { public static void main(String[] args) { TelephoneNumFrame frame = new TelephoneNumFrame();//主界面 frame.setDefaultCloseOperation(JFrame.EXIT_...
Java Vector的相关知识 Java Vector的相关知识
import java.util.*; import java.lang.*; /**the class used to show the image*/ public class DrawPanel extends JPanel { /**store each shape*/ public Vector<ImageInfo> store; /**the creation ...
import java.util.*; import javax.swing.*; import javax.swing.border.TitledBorder; import javax.swing.event.*; public class ChatServer extends JFrame { // used to read Username and Password from ...
ackage devin.wu.readbook.practice; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Vector; p...
可供程序利用的资源(内存、CPU时间...养成好的代码编写习惯非常重要,比如正确地、巧妙地运用java.lang.String类和java.util.Vector类,它能够显著地提高程序的性能。下面我们就来具体地分析一下这方面的问题。 .....
在Java程序中,性能问题的大部分原因并不在于Java语言,而是在于程序本身。养成好的代码编写习惯非常重要,比如正确地、巧妙地运用java.lang.String类和java.util.Vector类,它能够显著地提高程序的性能。
可供程序利用的资源(内存、CPU时间...养成好的代码编写习惯非常重要,比如正确地、巧妙地运用 java.lang.String类和java.util.Vector类,它能够 显着地提高程序的性能。下面我们就来具体地分析一下这方面的问题。 ……
import java.util.Vector; class ServerThread extends Thread{//继承线程 private Socket socket;//定义套接口 private BufferedReader in;//定义输入流 private PrintWriter out;//定义输出流 int no;//定义...
泛型集合12.3.4 泛型集合泛型的场景:定义泛型:12.3.5 Colletions工具类 ...import java.util.Vector; import java.util.ArrayList; import java.util.LinkedList; public class TestBasicGeneric { public s
// JAVA 新建 一个树的源代码 package com.xiangxiang.frame; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Vector;
通过java代码规范来优化程序,优化内存使用...养成好的代码编写习惯非常重要,比如正确地、巧妙地运用java.lang.String类和java.util.Vector类,它能够显著地提高程序的性能。下面我们就来具体地分析一下这方面的问题。