java.util.Vector#setElementAt ( )源码实例Demo

下面列出了java.util.Vector#setElementAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 *  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();
}
 
源代码2 项目: openjdk-8   文件: DefaultTableModel.java
/**
 *  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();
}
 
源代码3 项目: openjdk-8   文件: Whitespace.java
/**
 * 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;
        }
    }
}
 
源代码4 项目: dragonwell8_jdk   文件: DefaultTableModel.java
/**
 *  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();
}
 
源代码5 项目: openjdk-jdk9   文件: DefaultTableModel.java
/**
 *  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();
}
 
源代码6 项目: JDKSourceCode1.8   文件: Whitespace.java
/**
 * 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;
        }
    }
}
 
源代码7 项目: jdk8u60   文件: PolicyTool.java
/**
 * 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;
}
 
源代码8 项目: JDKSourceCode1.8   文件: DefaultTableModel.java
/**
 *  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();
}
 
源代码9 项目: jdk8u60   文件: AttributeValueTemplate.java
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
    final Vector contents = getContents();
    final int n = contents.size();
    for (int i = 0; i < n; i++) {
        final Expression exp = (Expression)contents.elementAt(i);
        if (!exp.typeCheck(stable).identicalTo(Type.String)) {
            contents.setElementAt(new CastExpr(exp, Type.String), i);
        }
    }
    return _type = Type.String;
}
 
源代码10 项目: openjdk-jdk8u   文件: DefaultTableModel.java
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);
    }
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: DefaultTableModel.java
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);
    }
}
 
源代码12 项目: openjdk-8-source   文件: DefaultTableModel.java
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);
    }
}
 
源代码13 项目: tomee   文件: IvmContext.java
protected void buildEnumeration(final Vector vect) {
    for (int i = 0; i < vect.size(); i++) {
        final NameNode node = (NameNode) vect.elementAt(i);
        final String className = node.getBinding().getClass().getName();
        vect.setElementAt(new Binding(node.getAtomicName(), className, node.getBinding()), i);
    }
    myEnum = vect.elements();
}
 
源代码14 项目: openjdk-8   文件: SetOfIntegerSyntax.java
/**
 * 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 项目: cropplanning   文件: JDBCTableModel.java
public void setValueAt(Object aValue, int aRow, int aCol) {
   Vector dataRow = (Vector) allRows.elementAt(aRow);
   dataRow.setElementAt(aValue, aCol);
   fireTableCellUpdated(aRow, aCol);
}
 
源代码16 项目: hottub   文件: SetOfIntegerSyntax.java
/**
 * 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;
            }
        }
    }
}
 
源代码17 项目: systemsgenetics   文件: VectorSorter.java
private static void swap(Vector a, int i, int j) {
Object T = a.elementAt(i);
a.setElementAt(a.elementAt(j), i);
a.setElementAt(T, j);
   }
 
源代码18 项目: jdk8u60   文件: DefaultTableModel.java
/**
 * 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) {
    Vector rowVector = (Vector)dataVector.elementAt(row);
    rowVector.setElementAt(aValue, column);
    fireTableCellUpdated(row, column);
}
 
源代码19 项目: jdk8u_jdk   文件: DefaultTableModel.java
/**
 * 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) {
    Vector rowVector = (Vector)dataVector.elementAt(row);
    rowVector.setElementAt(aValue, column);
    fireTableCellUpdated(row, column);
}
 
源代码20 项目: jdk8u-dev-jdk   文件: DefaultTableModel.java
/**
 * 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) {
    Vector rowVector = (Vector)dataVector.elementAt(row);
    rowVector.setElementAt(aValue, column);
    fireTableCellUpdated(row, column);
}