java.util.Vector.setSize()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中java.util.Vector.setSize()方法的一些代码示例,展示了Vector.setSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.setSize()方法的具体详情如下:
包路径:java.util.Vector
类名称:Vector
方法名:setSize

Vector.setSize介绍

[英]Sets the size of this vector to the specified size. If there are more than length elements in this vector, the elements at end are lost. If there are less than length elements in the vector, the additional elements contain null.
[中]将此向量的大小设置为指定的大小。如果此向量中有超过长度的元素,则末尾的元素将丢失。如果向量中的元素长度小于,则其他元素包含null。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Set the current size of the stack frame.
 */
void setCurrentStackFrameSize(int sz)
{
 m_variableNames.setSize(sz);
}

代码示例来源:origin: xalan/xalan

/**
 * Set the current size of the stack frame.
 */
void setCurrentStackFrameSize(int sz)
{
 m_variableNames.setSize(sz);
}

代码示例来源:origin: org.apache.poi/poi

/**
   * Ensures that the formats list can hold entries
   *  up to and including the entry with this index
   */
  private void ensureFormatsSize(int index) {
    if(_formats.size() <= index) {
     _formats.setSize(index+1);
    }
  }
}

代码示例来源:origin: plantuml/plantuml

/**
 * Generates all curves based on the specified data.
 * In addition the legend view is created.
 */
private void generateCurves(DataPlot dataPlot) {
 synchronized (_curves) {
  _legendView = new GraphicalComposite(null);
  _legendView.addElement(_legend.getBox());
  _curves.setSize(0);
  _nextCurveHints.setSize(0);
  for (int i = 0, n = dataPlot.getNumberOfElements(); i < n; i++) {
   Curve curve = _curveFactory.create(i, n, _clippingShape, _legend);
   _curves.addElement(curve);
   _nextCurveHints.addElement(new Vector());
   DataCurve dataCurve = (DataCurve) dataPlot.getElement(i);
   _legendView.addElement(curve.getLegendSymbol());
   _legendView.addElement(
     _legend.createCurveTitle(i, n, dataCurve.getTitle()));
   fillCurve(i, dataCurve);
  }
 }
}

代码示例来源:origin: robovm/robovm

m_prefixMappings.setSize(topContextIndex);

代码示例来源:origin: xalan/xalan

m_prefixMappings.setSize(topContextIndex);

代码示例来源:origin: robovm/robovm

m_prefixMappings.setSize(topContextIndex);

代码示例来源:origin: xalan/xalan

m_prefixMappings.setSize(topContextIndex);

代码示例来源:origin: javiersantos/PiracyChecker

public void setExpansionFileSize(int index, long size) {
  if (index >= mExpansionFileSizes.size()) {
    mExpansionFileSizes.setSize(index + 1);
  }
  mExpansionFileSizes.set(index, size);
}

代码示例来源:origin: javiersantos/PiracyChecker

public void setExpansionFileName(int index, String name) {
  if (index >= mExpansionFileNames.size()) {
    mExpansionFileNames.setSize(index + 1);
  }
  mExpansionFileNames.set(index, name);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  Clear any nested diagnostic information if any. This method is
  useful in cases where the same thread can be potentially used
  over and over in different unrelated contexts.
  <p>This method is equivalent to calling the {@link #setMaxDepth}
  method with a zero <code>maxDepth</code> argument.
  
  @since 0.8.4c */
public
static
void clear() {
 Stack stack = (Stack) ht.get(Thread.currentThread());    
 if(stack != null) 
  stack.setSize(0);    
}

代码示例来源:origin: javiersantos/PiracyChecker

/**
 * Sets the expansion URL. Expansion URL's are not committed to preferences, but are instead
 * intended to be stored when the license response is processed by the front-end.
 *
 * @param index
 *         the index of the expansion URL. This value will be either MAIN_FILE_URL_INDEX or
 *         PATCH_FILE_URL_INDEX
 * @param URL
 *         the URL to set
 */
public void setExpansionURL(int index, String URL) {
  if (index >= mExpansionURLs.size()) {
    mExpansionURLs.setSize(index + 1);
  }
  mExpansionURLs.set(index, URL);
}

代码示例来源:origin: linkedin/indextank-engine

/**
 * @param parameter zero-based parameter number
 */
public void addAnnotation(int parameter, Annotation annotation) {
  if (parameter >= mParameterAnnotations.size()) {
    mParameterAnnotations.setSize(parameter);
  }
  Vector<Annotation> annotations = mParameterAnnotations.get(parameter);
  if (annotations == null) {
    annotations = new Vector<Annotation>(2);
    mParameterAnnotations.set(parameter, annotations);
  }
  annotations.add(annotation);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  Set maximum depth of this diagnostic context. If the current
  depth is smaller or equal to <code>maxDepth</code>, then no
  action is taken.
  <p>This method is a convenient alternative to multiple {@link
  #pop} calls. Moreover, it is often the case that at the end of
  complex call sequences, the depth of the NDC is
  unpredictable. The <code>setMaxDepth</code> method circumvents
  this problem.
  <p>For example, the combination
  <pre>
   void foo() {
   &nbsp;  int depth = NDC.getDepth();
   &nbsp;  ... complex sequence of calls
   &nbsp;  NDC.setMaxDepth(depth);
   }
  </pre>
  ensures that between the entry and exit of foo the depth of the
  diagnostic stack is conserved.
  
  @see #getDepth
  @since 0.7.5 */
static
public
void setMaxDepth(int maxDepth) {
 Stack stack = (Stack) ht.get(Thread.currentThread());    
 if(stack != null && maxDepth < stack.size()) 
  stack.setSize(maxDepth);
}

代码示例来源:origin: linkedin/indextank-engine

/** 
 * Will only insert into the pool if the constant is not already in the
 * pool. 
 *
 * @return The actual constant in the pool.
 */
public ConstantInfo addConstant(ConstantInfo constant) {
  ConstantInfo info = mConstants.get(constant);
  if (info != null) {
    return info;
  }
  
  int entryCount = constant.getEntryCount();
  if (mIndexedConstants != null && mPreserveOrder) {
    int size = mIndexedConstants.size();
    mIndexedConstants.setSize(size + entryCount);
    mIndexedConstants.set(size, constant);
    constant.mIndex = size;
  }
  mConstants.put(constant, constant);
  mEntries += entryCount;
  return constant;
}

代码示例来源:origin: robovm/robovm

m_namespaceDeclSets.setSize(ds);

代码示例来源:origin: xalan/xalan

m_namespaceDeclSets.setSize(ds);

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Terminate the task running the queue, but only if there is a queue.
 */
synchronized void terminateQueue() {
if (q != null) {
  Vector<EventListener> dummyListeners = new Vector<EventListener>();
  dummyListeners.setSize(1); // need atleast one listener
  q.add(new QueueElement(new TerminatorEvent(), dummyListeners));
  q = null;
}
}

代码示例来源:origin: com.sun.mail/javax.mail

/**
 * 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;
}
}

代码示例来源:origin: org.apache.commons/commons-csv

@Test
public void testPrintRecordsWithEmptyVector() throws IOException {
  try (CSVPrinter csvPrinter = CSVFormat.POSTGRESQL_TEXT.printer()) {
    final Vector<CSVFormatTest.EmptyEnum> vector = new Vector<>();
    final int expectedCapacity = 23;
    vector.setSize(expectedCapacity);
    csvPrinter.printRecords(vector);
    assertEquals(expectedCapacity, vector.capacity());
  }
}

相关文章

微信公众号

最新文章

更多