java.util.LinkedList.toArray()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(159)

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

LinkedList.toArray介绍

[英]Returns an array containing all of the elements in this list in proper sequence (from first to last element).

The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.
[中]返回一个数组,该数组按正确顺序(从第一个元素到最后一个元素)包含此列表中的所有元素。
返回的数组将是“安全的”,因为此列表不维护对它的引用。(换句话说,此方法必须分配一个新数组)。因此,调用者可以自由修改返回的数组。
此方法充当基于阵列和基于集合的API之间的桥梁。

代码示例

代码示例来源:origin: aa112901/remusic

public TintInfo(LinkedList<int[]> stateList, LinkedList<Integer> colorList) {
  if (colorList == null || stateList == null) return;
  mTintColors = new int[colorList.size()];
  for (int i = 0; i < colorList.size(); i++)
    mTintColors[i] = colorList.get(i);
  mTintStates = stateList.toArray(new int[stateList.size()][]);
}

代码示例来源:origin: quartz-scheduler/quartz

private String[] split(String str, String splitStr) // Same as String.split(.) in JDK 1.4
{
  LinkedList<String> l = new LinkedList<String>();

  StringTokenizer strTok = new StringTokenizer(str, splitStr);
  while(strTok.hasMoreTokens()) {
    String tok = strTok.nextToken();
    l.add(tok);
  }

  return (String[])l.toArray(new String[l.size()]);
}

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

static StackTraceElement[] trimStackTrace(StackTraceElement[] stackTrace) {
 LinkedList<StackTraceElement> list = Lists.newLinkedList();
 for (int i = stackTrace.length - 1; i >= 0; i--) {
  StackTraceElement s = stackTrace[i];
  if (s.getClassName().startsWith(Checkers.class.getPackage().getName())) {
   break;
  }
  list.addLast(s);
 }
 return list.toArray(new StackTraceElement[list.size()]);
}

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

private static synchronized void addFieldGetter(FieldGetter fieldGetter, Integer index, boolean addLast) {
  checkParameter(fieldGetter);
  
  LinkedList<FieldGetter> ret = getCurrentFieldGetters();
  if (index != null) {
    ret.add(index, fieldGetter);
  } else {
    if (addLast) {
      ret.addLast(fieldGetter);
    } else {
      ret.addFirst(fieldGetter);
    }
  }
  getters = ret.toArray(new FieldGetter[ret.size()]);
}

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

private static X509Certificate[] createChain(X509Certificate  signer, X509Certificate[] candidates) {
  LinkedList chain = new LinkedList();
  chain.add(0, signer);
  // Signer is self-signed
  if (signer.getSubjectDN().equals(signer.getIssuerDN())){
    return (X509Certificate[])chain.toArray(new X509Certificate[1]);
  }
  Principal issuer = signer.getIssuerDN();
  X509Certificate issuerCert;
  int count = 1;
  while (true) {
    issuerCert = findCert(issuer, candidates);
    if( issuerCert == null) {
      break;
    }
    chain.add(issuerCert);
    count++;
    if (issuerCert.getSubjectDN().equals(issuerCert.getIssuerDN())) {
      break;
    }
    issuer = issuerCert.getIssuerDN();
  }
  return (X509Certificate[])chain.toArray(new X509Certificate[count]);
}

代码示例来源:origin: apache/accumulo

/**
 * Get a sorted List of all elements in this queue, in descending order.
 *
 * @return list of cached elements in descending order
 */
public CachedBlock[] get() {
 LinkedList<CachedBlock> blocks = new LinkedList<>();
 while (!queue.isEmpty()) {
  blocks.addFirst(queue.poll());
 }
 return blocks.toArray(new CachedBlock[blocks.size()]);
}

代码示例来源:origin: commons-collections/commons-collections

LinkedList keys = new LinkedList(Arrays.asList(topCities));
keys.addFirst("Minneapolis");
assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator);
comparator.setUnknownObjectBehavior(FixedOrderComparator.UNKNOWN_AFTER);
keys = new LinkedList(Arrays.asList(topCities));
keys.add("Minneapolis");
assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator);

代码示例来源:origin: org.codehaus.groovy/groovy

paras.add("-d");
paras.add(target.getAbsolutePath());
paras.add("-sourcepath");
paras.add(((File) options.get("stubDir")).getAbsolutePath());
return paras.toArray(EMPTY_STRING_ARRAY);

代码示例来源:origin: oracle/opengrok

res.add(name);
    res.add(name);
return res.size() == names.length ? names : res.toArray(new String[res
    .size()]);

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

public static synchronized void removeFieldGetter(Class<? extends FieldGetter> fieldGetterClass) {
    LinkedList<FieldGetter> ret = getCurrentFieldGetters();
    
    for (Iterator<FieldGetter> it = ret.iterator(); it.hasNext();) {
      if (it.next().getClass() == fieldGetterClass) {
        it.remove();
      }
    }
    
    getters = ret.toArray(new FieldGetter[ret.size()]);
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

FileObject[] results = new FileObject[list.size()];
list.toArray(results);

代码示例来源:origin: hankcs/HanLP

context.add(w.compiledWord + "i" + (i - index));      // 在尾巴上做个标记,不然特征冲突了
  context.add(w.label + "i" + (i - index));
  context.add(w.compiledWord + "j" + (i - index));      // 在尾巴上做个标记,不然特征冲突了
  context.add(w.label + "j" + (i - index));
context.add(wordBeforeI.label + '@' + nodeArray[from].label + '→' + nodeArray[to].label);
context.add(nodeArray[from].label + '→' + wordBeforeJ.label + '@' + nodeArray[to].label);
List<Pair<String, Double>> pairList = model.predict(context.toArray(new String[0]));
Pair<String, Double> maxPair = new Pair<String, Double>("null", -1.0);

代码示例来源:origin: org.netbeans.api/org-openide-nodes

/** Find a path (by name) from one node to the root or a parent.
 * @param node the node to start in
 * @param parent parent node to stop in (can be <code>null</code> for the root)
 * @return list of child names--i.e. a path from the parent to the child node
 * @exception IllegalArgumentException if <code>node</code>'s getName()
 * method returns <code>null</code>
 */
public static String[] createPath(Node node, Node parent) {
  LinkedList<String> ar = new LinkedList<String>();
  while ((node != null) && (node != parent)) {
    if (node.getName() == null) {
      boolean isFilter = false;
      if (node instanceof FilterNode) {
        isFilter = true;
      }
      throw new IllegalArgumentException(
        "Node:" + node.getClass() // NOI18N
         +"[" + node.getDisplayName() + "]" // NOI18N
         +(isFilter ? (" of original:" + ((FilterNode) node).getOriginal().getClass()) : "") // NOI18N
         +" gets null name!"
      ); // NOI18N
    }
    ar.addFirst(node.getName());
    node = node.getParentNode();
  }
  String[] res = new String[ar.size()];
  ar.toArray(res);
  return res;
}

代码示例来源:origin: cincheo/jsweet

args.add("--module");
  args.add(options.getModuleKind().toString());
args.add("--moduleResolution");
args.add(options.getModuleResolution().toString());
        transpilationHandler.report(JSweetProblem.INTERNAL_TSC_ERROR, null, "Unknown tsc error");
    }, args.toArray(new String[0]));

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

/**
 * 初始化官方默认 FieldGetter
 * 
 * 注意:
 * 默认不启用 IsMethodFieldGetter,用户可以通过下面的代码启用:
 * Engine.addLastFieldGetter(new FieldGetters.IsMethodFieldGetter());
 * 
 * 也可以通过直接调用 target.isXxx() 方法来达到与 target.xxx 表达式相同的目的
 */
private static FieldGetter[] init() {
  LinkedList<FieldGetter> ret = new LinkedList<FieldGetter>();
  
  ret.addLast(new GetterMethodFieldGetter(null));
  ret.addLast(new ModelFieldGetter());
  ret.addLast(new RecordFieldGetter());
  ret.addLast(new MapFieldGetter());
  ret.addLast(new RealFieldGetter(null));
  ret.addLast(new ArrayLengthGetter());
  // ret.addLast(new IsMethodFieldGetter());
  
  return ret.toArray(new FieldGetter[ret.size()]);
}

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

subjectAltList.add(s);
  String[] subjectAlts = new String[subjectAltList.size()];
  subjectAltList.toArray(subjectAlts);
  return subjectAlts;
} else {

代码示例来源:origin: apache/geode

/**
 * Write this stream to the specified channel. Call multiple times until size returns zero to make
 * sure all bytes in the stream have been written.
 *
 * @return the number of bytes written, possibly zero.
 * @throws IOException if channel is closed, not yet connected, or some other I/O error occurs.
 */
public int sendTo(SocketChannel chan) throws IOException {
 finishWriting();
 if (size() == 0) {
  return 0;
 }
 int result;
 if (this.chunks != null) {
  ByteBuffer[] bufs = new ByteBuffer[this.chunks.size() + 1];
  bufs = this.chunks.toArray(bufs);
  bufs[this.chunks.size()] = this.buffer;
  result = (int) chan.write(bufs);
 } else {
  result = chan.write(this.buffer);
 }
 this.size -= result;
 return result;
}

代码示例来源:origin: org.codehaus.groovy/groovy

private ClassNode[] makeGenericsBounds(AST rn, int boundType) {
  AST boundsRoot = rn.getNextSibling();
  if (boundsRoot == null) return null;
  assertNodeType(boundType, boundsRoot);
  LinkedList bounds = new LinkedList();
  for (AST boundsNode = boundsRoot.getFirstChild();
     boundsNode != null;
     boundsNode = boundsNode.getNextSibling()
      ) {
    ClassNode bound = null;
    bound = makeTypeWithArguments(boundsNode);
    configureAST(bound, boundsNode);
    bounds.add(bound);
  }
  if (bounds.isEmpty()) return null;
  return (ClassNode[]) bounds.toArray(ClassNode.EMPTY_ARRAY);
}

代码示例来源:origin: webx/citrus

private void postProcessTemplate(Template template, LinkedList<Map<String, Template>> templateStack) {
  templateStack.addFirst(template.subtemplates);
  // 处理nodes
  for (Node node : template.nodes) {
    postProcessNode(node, templateStack);
  }
  LinkedList<Node> nodes = createLinkedList(template.nodes);
  chomp(nodes);
  trimIfNeccessary(nodes, template.params);
  collapseWhitespacesIfNeccessary(nodes, template.params);
  template.nodes = nodes.toArray(new Node[nodes.size()]);
  // 递归处理子模板
  for (Template subTemplate : template.subtemplates.values()) {
    postProcessTemplate(subTemplate, templateStack);
  }
  templateStack.removeFirst();
}

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

int x = tok.indexOf("CN=");
  if(x >= 0) {
    cnList.add(tok.substring(x + 3));
  String[] cns = new String[cnList.size()];
  cnList.toArray(cns);
  return cns;
} else {

相关文章

微信公众号

最新文章

更多