本文整理汇总了Java中java.util.Vector.setElementAt方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.setElementAt方法的具体用法?Java Vector.setElementAt怎么用?Java Vector.setElementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Vector
的用法示例。
在下文中一共展示了Vector.setElementAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: triToTet
import java.util.Vector; //导入方法依赖的package包/类
/**
* Form a tetrahedron from vertex and the existing triangular hull.
*
* @param face - a triangular face of the tetrahedron
* @param vertex - the fourth point of the tetrahedron
* @param vol - indicates on which side of face vertex lies
*/
private void triToTet(Polygon face, Vertex vertex, int vol) {
Vector<Vertex> v = face.getVertices();
Vertex v1 = v.elementAt(0);
Vertex v2 = v.elementAt(1);
Vertex v3 = v.elementAt(2);
// Store the vertices in CCW order
if (vol < 0) {
v.setElementAt(v3, 0);
v.setElementAt(v1, 2);
Vertex tv = v1;
v1 = v3;
v3 = tv;
}
addFace(new Triangle(v3, v2, vertex));
addFace(new Triangle(v2, v1, vertex));
addFace(new Triangle(v1, v3, vertex));
}
示例2: addColumn
import java.util.Vector; //导入方法依赖的package包/类
/**
* Adds a column to the model. The new column will have the
* identifier <code>columnName</code>, which may be null.
* <code>columnData</code> is the
* optional vector of data for the column. If it is <code>null</code>
* the column is filled with <code>null</code> values. Otherwise,
* the new data will be added to model starting with the first
* element going to row 0, etc. This method will send a
* <code>tableChanged</code> notification message to all the listeners.
*
* @param columnName the identifier of the column being added
* @param columnData optional data of the column being added
*/
@SuppressWarnings("unchecked") // Adding element to raw columnIdentifiers
public void addColumn(Object columnName, Vector<?> columnData) {
columnIdentifiers.addElement(columnName);
if (columnData != null) {
int columnSize = columnData.size();
if (columnSize > getRowCount()) {
dataVector.setSize(columnSize);
}
justifyRows(0, getRowCount());
int newColumn = getColumnCount() - 1;
for(int i = 0; i < columnSize; i++) {
Vector<Object> row = dataVector.elementAt(i);
row.setElementAt(columnData.elementAt(i), newColumn);
}
}
else {
justifyRows(0, getRowCount());
}
fireTableStructureChanged();
}
示例3: addColumn
import java.util.Vector; //导入方法依赖的package包/类
/**
* Adds a column to the model. The new column will have the
* identifier <code>columnName</code>, which may be null.
* <code>columnData</code> is the
* optional vector of data for the column. If it is <code>null</code>
* the column is filled with <code>null</code> values. Otherwise,
* the new data will be added to model starting with the first
* element going to row 0, etc. This method will send a
* <code>tableChanged</code> notification message to all the listeners.
*
* @param columnName the identifier of the column being added
* @param columnData optional data of the column being added
*/
public void addColumn(Object columnName, Vector columnData) {
columnIdentifiers.addElement(columnName);
if (columnData != null) {
int columnSize = columnData.size();
if (columnSize > getRowCount()) {
dataVector.setSize(columnSize);
}
justifyRows(0, getRowCount());
int newColumn = getColumnCount() - 1;
for(int i = 0; i < columnSize; i++) {
Vector row = (Vector)dataVector.elementAt(i);
row.setElementAt(columnData.elementAt(i), newColumn);
}
}
else {
justifyRows(0, getRowCount());
}
fireTableStructureChanged();
}
示例4: partition
import java.util.Vector; //导入方法依赖的package包/类
/**
* Used with quicksort method above
*/
private static int partition(Vector rules, int p, int r) {
final WhitespaceRule x = (WhitespaceRule)rules.elementAt((p+r) >>> 1);
int i = p - 1, j = r + 1;
while (true) {
while (x.compareTo((WhitespaceRule)rules.elementAt(--j)) < 0) {
}
while (x.compareTo((WhitespaceRule)rules.elementAt(++i)) > 0) {
}
if (i < j) {
final WhitespaceRule tmp = (WhitespaceRule)rules.elementAt(i);
rules.setElementAt(rules.elementAt(j), i);
rules.setElementAt(tmp, j);
}
else {
return j;
}
}
}
示例5: addPermEntry
import java.util.Vector; //导入方法依赖的package包/类
/**
* Add a Permission entry to an existing PolicyEntry at the specified index.
* A Permission entry consists of a permission, name, and actions.
*
* If the permission already exists, it is not added again.
*/
boolean addPermEntry(PolicyEntry pe,
PolicyParser.PermissionEntry newPerm,
int index) {
// first add the permission to the Policy Parser Vector
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPerm) == true)
return false;
Vector<PolicyParser.PermissionEntry> permList =
grantEntry.permissionEntries;
if (index != -1)
permList.setElementAt(newPerm, index);
else
permList.addElement(newPerm);
modified = true;
return true;
}
示例6: setDatum
import java.util.Vector; //导入方法依赖的package包/类
private void setDatum(int row, int column, String value) {
Vector<String> col = dataColumnVector.get(column);
if (row >= col.size()) {
col.addElement(value);
if (row >= rowCount) {
rowCount = row + 1;
}
} else {
col.setElementAt(value, row);
}
dataControl.setMaxRows(Math.max(dataControl.getMaxRows(), col.size()));
dataControl.setMaxColumns(Math.max(dataControl.getMaxColumns(), dataColumnVector.size()));
}
示例7: setEntryAt
import java.util.Vector; //导入方法依赖的package包/类
/**
* Sets the entry of a table.
*
* @param poNonTerminal the non-terminal as a row index
* @param poTerminal the terminal as a column index
* @param poEntry the entry to set
* @throws ArrayIndexOutOfBoundsException if either index does not exist
*/
public void setEntryAt(final NonTerminal poNonTerminal, final Terminal poTerminal, Object poEntry) {
try {
Vector oRow = (Vector) this.oTT.elementAt(poNonTerminal.getID());
oRow.setElementAt(poEntry, poTerminal.getID());
} catch (ArrayIndexOutOfBoundsException e) {
throw new ArrayIndexOutOfBoundsException
(
"TransitinTable::setEntryAt() - Out of boundaries.\n"
+ "TerminalID=" + poTerminal.getID()
+ ", NonTerminalID=" + poNonTerminal.getID()
);
}
}
示例8: rotate
import java.util.Vector; //导入方法依赖的package包/类
private static void rotate(Vector v, int a, int b, int shift) {
int size = b - a;
int r = size - shift;
int g = gcd(size, r);
for(int i = 0; i < g; i++) {
int to = i;
Object tmp = v.elementAt(a + to);
for(int from = (to + r) % size; from != i; from = (to + r) % size) {
v.setElementAt(v.elementAt(a + from), a + to);
to = from;
}
v.setElementAt(tmp, a + to);
}
}
示例9: rotate
import java.util.Vector; //导入方法依赖的package包/类
private static <E> void rotate(Vector<E> v, int a, int b, int shift) {
int size = b - a;
int r = size - shift;
int g = gcd(size, r);
for(int i = 0; i < g; i++) {
int to = i;
E tmp = v.elementAt(a + to);
for(int from = (to + r) % size; from != i; from = (to + r) % size) {
v.setElementAt(v.elementAt(a + from), a + to);
to = from;
}
v.setElementAt(tmp, a + to);
}
}
示例10: swap
import java.util.Vector; //导入方法依赖的package包/类
private static void swap(Vector<Object> v, int i, int j) {
Object tmp = v.elementAt(i);
v.setElementAt(v.elementAt(j), i);
v.setElementAt(tmp, j);
}
示例11: testSpeed
import java.util.Vector; //导入方法依赖的package包/类
public void testSpeed() {
randomGenerator = new Random(System.currentTimeMillis());
int TEST_RUNS = 100000;
int LOOP_COUNT = 1000;
HsqlArrayList arrayList = new HsqlArrayList(TEST_RUNS);
ArrayList utilArrayList = new ArrayList(TEST_RUNS);
Vector vector = new Vector(TEST_RUNS);
Integer value = new Integer(randomGenerator.nextInt());
Integer INT_0 = new Integer(0);
StopWatch sw = new StopWatch();
System.out.println(sw.currentElapsedTimeToMessage("time"));
for (int i = 0; i < TEST_RUNS; i++) {
arrayList.add(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
arrayList.set(i, INT_0);
}
}
System.out.println(
sw.currentElapsedTimeToMessage("time HsqlArrayLsit"));
sw.zero();
for (int i = 0; i < TEST_RUNS; i++) {
utilArrayList.add(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
utilArrayList.set(i, INT_0);
}
}
System.out.println(sw.currentElapsedTimeToMessage("time ArrayList"));
sw.zero();
for (int i = 0; i < TEST_RUNS; i++) {
vector.addElement(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
vector.setElementAt(INT_0, i);
}
}
System.out.println(sw.currentElapsedTimeToMessage("time Vector"));
}
示例12: accumulate
import java.util.Vector; //导入方法依赖的package包/类
/**
* Accumulate the given range (lb .. ub) into the canonical array form into
* the given vector of int[] objects.
*/
private static void accumulate(Vector<int[]> ranges, int lb,int ub) {
// Make sure range is non-null.
if (lb <= ub) {
// Stick range at the back of the vector.
ranges.add(new int[] {lb, ub});
// Work towards the front of the vector to integrate the new range
// with the existing ranges.
for (int j = ranges.size()-2; j >= 0; -- j) {
// Get lower and upper bounds of the two ranges being compared.
int[] rangea = ranges.elementAt (j);
int lba = rangea[0];
int uba = rangea[1];
int[] rangeb = ranges.elementAt (j+1);
int lbb = rangeb[0];
int ubb = rangeb[1];
/*
* If the two ranges overlap or are adjacent, coalesce them. The
* two ranges overlap if the larger lower bound is less than or
* equal to the smaller upper bound. The two ranges are adjacent
* if the larger lower bound is one greater than the smaller
* upper bound.
*/
if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
// The coalesced range is from the smaller lower bound to
// the larger upper bound.
ranges.setElementAt(new int[]
{Math.min(lba, lbb),
Math.max(uba, ubb)}, j);
ranges.remove (j+1);
} else if (lba > lbb) {
/* If the two ranges don't overlap and aren't adjacent but
* are out of order, swap them.
*/
ranges.setElementAt (rangeb, j);
ranges.setElementAt (rangea, j+1);
} else {
/*
* If the two ranges don't overlap and aren't adjacent and
* aren't out of order, we're done early.
*/
break;
}
}
}
}
示例13: testSpeed
import java.util.Vector; //导入方法依赖的package包/类
public void testSpeed() {
randomGenerator = new Random(System.currentTimeMillis());
int TEST_RUNS = 100000;
int LOOP_COUNT = 1000;
HsqlArrayList arrayList = new HsqlArrayList(TEST_RUNS);
ArrayList utilArrayList = new ArrayList(TEST_RUNS);
Vector vector = new Vector(TEST_RUNS);
Integer value = new Integer(randomGenerator.nextInt());
Integer INT_0 = new Integer(0);
StopWatch sw = new StopWatch();
System.out.println(sw.currentElapsedTimeToMessage("time"));
for (int i = 0; i < TEST_RUNS; i++) {
arrayList.add(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
arrayList.set(i, INT_0);
}
}
System.out.println(sw.currentElapsedTimeToMessage("time"));
sw.zero();
for (int i = 0; i < TEST_RUNS; i++) {
utilArrayList.add(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
utilArrayList.set(i, INT_0);
}
}
System.out.println(sw.currentElapsedTimeToMessage("time"));
sw.zero();
for (int i = 0; i < TEST_RUNS; i++) {
vector.addElement(INT_0);
}
for (int i = 0; i < TEST_RUNS; i++) {
for (int j = 0; j < LOOP_COUNT; j++) {
vector.setElementAt(INT_0, i);
}
}
System.out.println(sw.currentElapsedTimeToMessage("time"));
}
示例14: accumulate
import java.util.Vector; //导入方法依赖的package包/类
/**
* Accumulate the given range (lb .. ub) into the canonical array form
* into the given vector of int[] objects.
*/
private static void accumulate(Vector ranges, int lb,int ub) {
// Make sure range is non-null.
if (lb <= ub) {
// Stick range at the back of the vector.
ranges.add(new int[] {lb, ub});
// Work towards the front of the vector to integrate the new range
// with the existing ranges.
for (int j = ranges.size()-2; j >= 0; -- j) {
// Get lower and upper bounds of the two ranges being compared.
int[] rangea = (int[]) ranges.elementAt (j);
int lba = rangea[0];
int uba = rangea[1];
int[] rangeb = (int[]) ranges.elementAt (j+1);
int lbb = rangeb[0];
int ubb = rangeb[1];
/* If the two ranges overlap or are adjacent, coalesce them.
* The two ranges overlap if the larger lower bound is less
* than or equal to the smaller upper bound. The two ranges
* are adjacent if the larger lower bound is one greater
* than the smaller upper bound.
*/
if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
// The coalesced range is from the smaller lower bound to
// the larger upper bound.
ranges.setElementAt(new int[]
{Math.min(lba, lbb),
Math.max(uba, ubb)}, j);
ranges.remove (j+1);
} else if (lba > lbb) {
/* If the two ranges don't overlap and aren't adjacent but
* are out of order, swap them.
*/
ranges.setElementAt (rangeb, j);
ranges.setElementAt (rangea, j+1);
} else {
/* If the two ranges don't overlap and aren't adjacent and
* aren't out of order, we're done early.
*/
break;
}
}
}
}
示例15: setValueAt
import java.util.Vector; //导入方法依赖的package包/类
/**
* Sets the object value for the cell at <code>column</code> and
* <code>row</code>. <code>aValue</code> is the new value. This method
* will generate a <code>tableChanged</code> notification.
*
* @param aValue the new value; this can be null
* @param row the row whose value is to be changed
* @param column the column whose value is to be changed
* @exception ArrayIndexOutOfBoundsException if an invalid row or
* column was given
*/
public void setValueAt(Object aValue, int row, int column) {
@SuppressWarnings("unchecked")
Vector<Object> rowVector = dataVector.elementAt(row);
rowVector.setElementAt(aValue, column);
fireTableCellUpdated(row, column);
}