当前位置: 首页>>代码示例>>Java>>正文


Java Vector.setElementAt方法代码示例

本文整理汇总了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));
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:26,代码来源:ConvexHull.java

示例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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:DefaultTableModel.java

示例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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:DefaultTableModel.java

示例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;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:Whitespace.java

示例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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:PolicyTool.java

示例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()));
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:AttributeEditor.java

示例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()
                );
    }
}
 
开发者ID:souhaib100,项目名称:MARF-for-Android,代码行数:22,代码来源:TransitionTable.java

示例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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:DefaultTableModel.java

示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:DefaultTableModel.java

示例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);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:6,代码来源:Sort.java

示例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"));
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:55,代码来源:TestDataStructures.java

示例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;
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:SetOfIntegerSyntax.java

示例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"));
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:54,代码来源:TestDataStructures.java

示例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;
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:51,代码来源:SetOfIntegerSyntax.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DefaultTableModel.java


注:本文中的java.util.Vector.setElementAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。