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

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

源代码1 项目: openjdk-jdk9   文件: VectorTest.java
/**
 * tests for setSize()
 */
public void testSetSize() {
    final Vector v = new Vector();
    for (int n : new int[] { 100, 5, 50 }) {
        v.setSize(n);
        assertEquals(n, v.size());
        assertNull(v.get(0));
        assertNull(v.get(n - 1));
        assertThrows(
                ArrayIndexOutOfBoundsException.class,
                new Runnable() { public void run() { v.setSize(-1); }});
        assertEquals(n, v.size());
        assertNull(v.get(0));
        assertNull(v.get(n - 1));
    }
}
 
源代码2 项目: spliceengine   文件: ClassHolder.java
protected ClassHolder(int estimatedConstantPoolCount) {
	// Constant Pool Information
	// 100 is the estimate of the number of entries that will be generated
	cptEntries = new Vector(estimatedConstantPoolCount);
	cptHashTable = new Hashtable(estimatedConstantPoolCount, (float)0.75);

	// reserve the 0'th constant pool entry
	cptEntries.setSize(1);
}
 
源代码3 项目: pluotsorbet   文件: VerifyFrame.java
public Vector getFrame(int count) throws jasError
{
  if(count > locals.size())
      throw new jasError("Counter exceed range", true);
  Vector result = new Vector(locals);
  if(count != 0)  // else -- full copy
      result.setSize(count);
  return result;
}
 
源代码4 项目: FairEmail   文件: EventQueue.java
/**
    * Terminate the task running the queue, but only if there is a queue.
    */
   synchronized void terminateQueue() {
if (q != null) {
    Vector<EventListener> dummyListeners = new Vector<>();
    dummyListeners.setSize(1); // need atleast one listener
    q.add(new QueueElement(new TerminatorEvent(), dummyListeners));
    q = null;
}
   }
 
源代码5 项目: TFC2   文件: DelaunayUtil.java
public static Object getAtPosition(Vector v, int index)
{
	if(index > v.size())
	{
		v.setSize(index+1);
	}
	try
	{
		return v.get(index);
	}
	catch(IndexOutOfBoundsException e)
	{
		return null;
	}
}
 
源代码6 项目: gemfirexd-oss   文件: ClassHolder.java
protected ClassHolder(int estimatedConstantPoolCount) {
	// Constant Pool Information
	// 100 is the estimate of the number of entries that will be generated
	cptEntries = new Vector(estimatedConstantPoolCount);
	cptHashTable = new Hashtable(estimatedConstantPoolCount, (float)0.75);

	// reserve the 0'th constant pool entry
	cptEntries.setSize(1);
}
 
源代码7 项目: jaybird   文件: MessageLoader.java
private void storeValue(int errorCode, String value, Vector<String> facilityVector) {
    if (facilityVector == null) {
        log.warn("Invalid error code " + errorCode + ", no valid facility; skipping");
        return;
    }
    final int code = MessageLookup.getCode(errorCode);
    if (facilityVector.size() <= code) {
        facilityVector.setSize(code + 1);
    }
    facilityVector.set(code, value);
}
 
源代码8 项目: TencentKona-8   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码9 项目: jdk8u60   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码10 项目: JDKSourceCode1.8   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码11 项目: jdk8u-dev-jdk   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码13 项目: Carbonado   文件: GenericEncodingStrategy.java
/**
 * Generates code that decodes property states from
 * ((properties.length + 3) / 4) bytes.
 *
 * @param encodedVar references a byte array
 * @param offset offset into byte array
 * @return local variables with state values
 */
private List<LocalVariable> decodePropertyStates(CodeAssembler a, LocalVariable encodedVar,
                                                 int offset, StorableProperty<S>[] properties)
{
    Vector<LocalVariable> stateVars = new Vector<LocalVariable>();
    LocalVariable accumVar = a.createLocalVariable(null, TypeDesc.INT);
    int accumShift = 8;

    for (int i=0; i<properties.length; i++) {
        StorableProperty<S> property = properties[i];

        int stateVarOrdinal = property.getNumber() >> 4;
        stateVars.setSize(Math.max(stateVars.size(), stateVarOrdinal + 1));

        if (stateVars.get(stateVarOrdinal) == null) {
            stateVars.set(stateVarOrdinal, a.createLocalVariable(null, TypeDesc.INT));
            a.loadThis();
            a.loadField(PROPERTY_STATE_FIELD_NAME + stateVarOrdinal, TypeDesc.INT);
            a.storeLocal(stateVars.get(stateVarOrdinal));
        }

        if (accumShift >= 8) {
            // Load accumulator byte.
            a.loadLocal(encodedVar);
            a.loadConstant(offset++);
            a.loadFromArray(TypeDesc.BYTE);
            a.loadConstant(0xff);
            a.math(Opcode.IAND);
            a.storeLocal(accumVar);
            accumShift = 0;
        }

        int stateShift = (property.getNumber() & 0xf) * 2;

        int accumPack = 2;
        int mask = PROPERTY_STATE_MASK << stateShift;

        // Try to pack more state properties into one operation.
        while ((accumShift + accumPack) < 8) {
            if (i + 1 >= properties.length) {
                // No more properties to encode.
                break;
            }
            StorableProperty<S> nextProperty = properties[i + 1];
            if (property.getNumber() + 1 != nextProperty.getNumber()) {
                // Properties are not consecutive.
                break;
            }
            if (stateVarOrdinal != (nextProperty.getNumber() >> 4)) {
                // Property states are stored in different fields.
                break;
            }
            accumPack += 2;
            mask |= PROPERTY_STATE_MASK << ((nextProperty.getNumber() & 0xf) * 2);
            property = nextProperty;
            i++;
        }

        a.loadLocal(accumVar);

        if (stateShift < accumShift) {
            a.loadConstant(accumShift - stateShift);
            a.math(Opcode.IUSHR);
        } else if (stateShift > accumShift) {
            a.loadConstant(stateShift - accumShift);
            a.math(Opcode.ISHL);
        }

        a.loadConstant(mask);
        a.math(Opcode.IAND);
        a.loadLocal(stateVars.get(stateVarOrdinal));
        a.loadConstant(~mask);
        a.math(Opcode.IAND);
        a.math(Opcode.IOR);
        a.storeLocal(stateVars.get(stateVarOrdinal));

        accumShift += accumPack;
    }

    return stateVars;
}
 
源代码14 项目: openjdk-jdk9   文件: DefaultTableModel.java
private static <E> Vector<E> newVector(int size) {
    Vector<E> v = new Vector<>(size);
    v.setSize(size);
    return v;
}
 
源代码15 项目: jdk8u-jdk   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码16 项目: hottub   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码17 项目: jdk8u-jdk   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码18 项目: megan-ce   文件: Biom1ExportTaxonomy.java
/**
 * recursively visit all the selected leaves
 *
 * @param viewer
 * @param v
 * @param selected
 * @param path
 * @param rowList
 * @param dataList
 */
private static void visitSelectedLeavesRec(MainViewer viewer, Node v, NodeSet selected, Vector<String> path,
                                           LinkedList<Map> rowList, LinkedList<float[]> dataList, boolean officialRanksOnly, ProgressListener progressListener) throws CanceledException {

    if (v.getOutDegree() > 0 || selected.contains(v)) {
        final Integer taxId = (Integer) v.getInfo();
        String taxName = v == viewer.getTree().getRoot() ? "Root" : TaxonomyData.getName2IdMap().get(taxId);
        {
            int a = taxName.indexOf("<");
            int b = taxName.lastIndexOf(">");
            if (0 < a && a < b && b == taxName.length() - 1)
                taxName = taxName.substring(0, a).trim(); // remove trailing anything in < > brackets
        }
        final int rank = TaxonomyData.getTaxonomicRank(taxId);
        boolean addedPathElement = false;

        if (!officialRanksOnly || TaxonomicLevels.isMajorRank(rank)) {
            if (officialRanksOnly) {
                char letter = Character.toLowerCase(TaxonomicLevels.getName(rank).charAt(0));
                path.addElement(String.format("%c__%s", letter, taxName));
            } else
                path.addElement(taxName);
            addedPathElement = true;

            if (selected.contains(v)) {
                NodeData nodeData = viewer.getNodeData(v);
                if (nodeData != null) {
                    float[] values;
                    if (v.getOutDegree() == 0)
                        values = nodeData.getSummarized();
                    else
                        values = nodeData.getAssigned();
                    final Map<String, Object> rowItem = new StringMap<>();
                    rowItem.put("id", "" + taxId);
                    final Map<String, Object> metadata = new StringMap<>();
                    final ArrayList<String> classification = new ArrayList<>(path.size());
                    classification.addAll(path);
                    metadata.put("taxonomy", classification);
                    rowItem.put("metadata", metadata);
                    rowList.add(rowItem);
                    dataList.add(values);
                }
            }
        }
        progressListener.incrementProgress();

        for (Edge e = v.getFirstOutEdge(); e != null; e = v.getNextOutEdge(e)) {
            visitSelectedLeavesRec(viewer, e.getTarget(), selected, path, rowList, dataList, officialRanksOnly, progressListener);
        }
        if (addedPathElement)
            path.setSize(path.size() - 1);
    }
}
 
源代码19 项目: openjdk-8   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}
 
源代码20 项目: jdk8u_jdk   文件: DefaultTableModel.java
private static Vector newVector(int size) {
    Vector v = new Vector(size);
    v.setSize(size);
    return v;
}