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

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

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

LinkedList.addFirst介绍

[英]Inserts the specified element at the beginning of this list.
[中]在此列表的开头插入指定的元素。

代码示例

代码示例来源:origin: prestodb/presto

public void prependPath(Reference r)
{
  if (_path == null) {
    _path = new LinkedList<Reference>();
  }
  /* Also: let's not increase without bounds. Could choose either
   * head or tail; tail is easier (no need to ever remove), as
   * well as potentially more useful so let's use it:
   */
  if (_path.size() < MAX_REFS_TO_LIST) {
    _path.addFirst(r);
  }
}

代码示例来源:origin: Atmosphere/atmosphere

public AtmosphereObjectFactory allowInjectionOf(Injectable<?> injectable, boolean first) {
  if (first) {
    injectables.addFirst(injectable);
  } else {
    injectables.add(injectable);
  }
  return this;
}

代码示例来源:origin: stanfordnlp/CoreNLP

public List<T> asSortedList() {
 LinkedList<T> list = new LinkedList<>();
 for (Iterator<T> i = elements.iterator(); i.hasNext();) {
  list.addFirst(i.next());
 }
 return list;
}

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

LinkedList<ValidationProvider<?>> providers = new LinkedList<ValidationProvider<?>>();
while (providerIterator.hasNext()) {
  try {
    ValidationProvider<?> provider = providerIterator.next();
      providers.addFirst(provider);
    } else {
      providers.add(provider);

代码示例来源:origin: EngineHub/WorldEdit

String operator = null;
for (Iterator<Identifiable> it = input.descendingIterator(); it.hasNext();) {
  Identifiable identifiable = it.next();
  if (operator == null) {
    rhs.addFirst(identifiable);
    rhs.removeFirst();
  } else {
    lhs.addFirst(identifiable);
  return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable);
} catch (NoSuchMethodException e) {
  final Token operatorToken = (Token) input.get(lhs.size());
  throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'");

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

wordLinkedList.addFirst(new Word(Predefine.TAG_BIGIN, "S"));
wordLinkedList.addLast(new Word(Predefine.TAG_END, "Z"));
if (verbose) System.out.println("添加首尾 " + wordList);
IWord pre = iterator.next();
while (iterator.hasNext())
  IWord current = iterator.next();
  if (current.getLabel().startsWith("nt") && !pre.getLabel().startsWith("nt"))
pre = iterator.next();
while (iterator.hasNext())
  IWord current = iterator.next();
  IWord first = iterator.next();
  IWord second = iterator.next();
  while (iterator.hasNext())
    IWord third = iterator.next();

代码示例来源:origin: stanfordnlp/CoreNLP

boolean addedBe = false;
boolean addedSuffix = false;
if (body.size() > 1 && !"PRP".equals(body.get(0).tag())) {
 for (int i = 2; i < body.size(); ++i) {
  CoreLabel tokI = body.get(i);
  if (tokI.tag() != null &&
     i += 1;
    body.add(i, suffix.get(0));
    addedSuffix = true;
 body.add(prepNum.get(0));
 body.add(WORD_IN);
 body.add(prepNum.get(1));
    be.forEach(body::addFirst);
   body.addFirst(WORD_MISSING);
   Iterator<CoreLabel> beIter = be.iterator();
   if (beIter.hasNext() && body.getLast() == beIter.next()) {
    body.removeLast();

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

if (!locs.isEmpty()) {
    if (cand.serializable()) {
      Iterator<GridCacheMvccCandidate> it = locs.descendingIterator();
        while (it.hasNext()) {
          GridCacheMvccCandidate c = it.next();
        while (it.hasNext()) {
          GridCacheMvccCandidate c = it.next();
        cand.setReentry();
        locs.addFirst(cand);
    for (ListIterator<GridCacheMvccCandidate> it = locs.listIterator(locs.size()); it.hasPrevious(); ) {
      GridCacheMvccCandidate c = it.previous();
  locs.addFirst(cand);
  locs.add(cand);
rmts.add(cand);

代码示例来源:origin: Sable/soot

while (sbit.hasNext()) {
 IterableSet body = sbit.next();
 IterableSet children = SETParent.get_Body2ChildChain().get(body);
  worklist.add(SETBasicBlock.get_SETBasicBlock(startSETNode));
  find_entry_loop: while (bit.hasNext()) {
   AugmentedStmt as = (AugmentedStmt) bit.next();
   while (pbit.hasNext()) {
    if (body.contains(pbit.next()) == false) {
     startSETNode = as.myNode;
     break find_entry_loop;
  worklist.add(SETBasicBlock.get_SETBasicBlock(startSETNode));
    worklist.add(SETBasicBlock.get_SETBasicBlock(child));
 while (worklist.isEmpty() == false) {
  SETBasicBlock sbb = (SETBasicBlock) worklist.removeFirst();
  while (sit.hasNext()) {
   worklist.addFirst(sit.next());

代码示例来源:origin: org.assertj/assertj-core

Set<Object> visited = new HashSet<>();
LinkedList<Object> stack = new LinkedList<>();
stack.addFirst(obj);
int hash = 0;
while (!stack.isEmpty()) {
 obj = stack.removeFirst();
 if (obj == null || visited.contains(obj)) {
  continue;
  int len = Array.getLength(obj);
  for (int i = 0; i < len; i++) {
   stack.addFirst(Array.get(obj, i));
  stack.add(Math.round(((Number) obj).doubleValue()));
  continue;
  stack.addFirst(COMPARISON.getSimpleValue(field.getName(), obj));

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

protected void flattenTree() {
 flattenedList = new LinkedList<ExecutionTreeNode>();
 LinkedList<ExecutionTreeNode> nodesToHandle = new LinkedList<ExecutionTreeNode>();
 nodesToHandle.add(rootNode);
 while (!nodesToHandle.isEmpty()) {
  ExecutionTreeNode currentNode = nodesToHandle.pop();
  if (reverseOrder) {
   flattenedList.addFirst(currentNode);
  } else {
   flattenedList.add(currentNode);
  }
  if (currentNode.getChildren() != null && currentNode.getChildren().size() > 0) {
   for (ExecutionTreeNode childNode : currentNode.getChildren()) {
    nodesToHandle.add(childNode);
   }
  }
 }
 flattenedListIterator = flattenedList.iterator();
}

代码示例来源: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: fusesource/mqtt-client

void putBackMessage(Message msg) {
  if( receiveFutures.isEmpty() ) {
    receivedFrames.addFirst(msg);
  } else {
    receiveFutures.removeFirst().onSuccess(msg);
  }
}

代码示例来源:origin: wiztools/rest-client

@Override
public void add(Request request) {
  if(cursor != 0) { // discard everything newer than cursor position
    for(int i=0; i<cursor; i++) {
      data.removeFirst();
    }
  }
  
  // Add:
  data.addFirst(request);
  
  // Verify if threshold reached:
  if(data.size() > maxSize) {
    data.removeLast();
  }
  
  // reset cursor:
  cursor = 0;
}

代码示例来源:origin: seven332/EhViewer

mWaitList.add(info);
  return;
list.addFirst(info);
mAllInfoList.addFirst(info);
mAllInfoMap.put(galleryInfo.gid, info);
mWaitList.add(info);
  l.onAdd(info, list, list.size() - 1);

代码示例来源:origin: k9mail/k-9

@Override
public void startMessage() {
  if (stack.isEmpty()) {
    stack.addFirst(MimeMessage.this);
  } else {
    expect(Part.class);
    Part part = (Part) stack.peek();
    MimeMessage m = new MimeMessage();
    part.setBody(m);
    stack.addFirst(m);
  }
}

代码示例来源:origin: org.testng/testng

queue.addLast(o);
while (! queue.isEmpty()) {
 for (T obj : getPredecessors(queue.removeFirst())) {
  if (! visited.contains(obj)) {
   visited.add(obj);
   queue.addLast(obj);
   result.addFirst(obj);

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

for(int x = loopCount; x > 0; x--) {
  ll.addFirst(o1);
  ll.addLast(o2);
  ll.removeFirst();
  ll.removeLast();
  ll.add(o1);
  ll.remove(0);
  ll.addFirst(o1);
  ll.addLast(o2);
  ll.removeFirst();
  ll.removeLast();
  ll.add(o1);
  ll.remove(0);
  ll.addFirst(o1);
  ll.addLast(o2);
  ll.removeFirst();
  ll.removeLast();
  ll.add(o1);
  ll.remove(0);

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

@Override
public List<OutboundSecurityProvider> selectOutboundProviders() {
  LinkedList<OutboundSecurityProvider> result = new LinkedList<>();
  // only add the ones we are not composing
  allOutbound.stream()
      .filter(np -> !configuredOutbound.contains(np.getName()))
      .forEach(np -> result.add(np.getProvider()));
  if (null != outbound) {
    if (isDefault) {
      result.addFirst(outbound);
    } else {
      result.addLast(outbound);
    }
  }
  return result;
}

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

if (!asyncRequests.isEmpty()) {
 if (!session.tryUse(false)) {
  return true; // Session has expired and will be returned to us later.
  pool.addFirst(session);
 } else {
  pool.addLast(session);

相关文章