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

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

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

LinkedList.removeFirst介绍

[英]Removes and returns the first element from this list.
[中]从此列表中删除并返回第一个元素。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

private AST pop() {
  if ( parents.size() == 0 ) {
    return null;
  }
  else {
    return parents.removeFirst();
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

/**
 *  Retrieves and removes an extracted message from the accumulated buffer
 *  or returns null if there are no more messages.
 */
public Message getMessage()
{
  if( messages.isEmpty() ) {
    return null;
  }
  
  return messages.removeFirst();
}

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

public void samplingInMinutes() {
  synchronized (this.csListHour) {
    this.csListHour.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
      .get()));
    if (this.csListHour.size() > 7) {
      this.csListHour.removeFirst();
    }
  }
}

代码示例来源:origin: ethereum/ethereumj

private synchronized boolean onTransactions(List<Transaction> txs) {
  if (txs.isEmpty()) return false;
  long[] gasPrices = new long[txs.size()];
  for (int i = 0; i < txs.size(); ++i) {
    gasPrices[i] = ByteUtil.byteArrayToLong(txs.get(i).getGasPrice());
  }
  blockGasPrices.add(gasPrices);
  while (blockGasPrices.size() > getMinBlocks() &&
      (calcGasPricesSize() - blockGasPrices.getFirst().length) >= getMinTransactions()) {
    blockGasPrices.removeFirst();
  }
  return true;
}

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

private void buildIndex() {
  LinkedList<TreeNode> queue = new LinkedList<>();
  queue.add(root);
  while (!queue.isEmpty()) {
    TreeNode node = queue.removeFirst();
    index.put(node.cuboidId, node);
    for (TreeNode child : node.children) {
      queue.add(child);
    }
  }
}

代码示例来源:origin: apache/incubator-dubbo

Integer old = index;
if (index == null) {
  index = history.size() - 1;
} else {
  if (up) {
    index = index - 1;
    if (index < 0) {
      index = history.size() - 1;
    if (index > history.size() - 1) {
      index = 0;
  channel.setAttribute(HISTORY_LIST_KEY, history);
if (history.isEmpty()) {
  history.addLast(result);
} else if (!result.equals(history.getLast())) {
  history.remove(result);
  history.addLast(result);
  if (history.size() > 10) {
    history.removeFirst();

代码示例来源:origin: fesh0r/fernflower

private static boolean insertNestedClass(ClassNode root, ClassNode child) {
 Set<String> setEnclosing = child.enclosingClasses;
 LinkedList<ClassNode> stack = new LinkedList<>();
 stack.add(root);
 while (!stack.isEmpty()) {
  ClassNode node = stack.removeFirst();
  if (setEnclosing.contains(node.classStruct.qualifiedName)) {
   node.nested.add(child);
   child.parent = node;
   return true;
  }
  // note: ordered list
  stack.addAll(node.nested);
 }
 return false;
}

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

@Override
  public void run() {
    snapshotList.addLast(statsBenchmark.createSnapshot());
    if (snapshotList.size() > 10) {
      snapshotList.removeFirst();
    }
  }
}, 1000, 1000);

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

public boolean hasMoreData() {
  while (!sources.isEmpty() && !((DoubleDataSource) sources.getFirst()).hasMoreData()) {
    sources.removeFirst();
  }
  if (sources.isEmpty())
    return false;
  return true;
}

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

public BitSet getTransitiveOutputSet(int input) {
  BitSet visited = new BitSet();
  BitSet result = new BitSet();
  LinkedList<Integer> workList = new LinkedList<>();
  workList.addLast(input);
  while (!workList.isEmpty()) {
    Integer valueNumber = workList.removeFirst();
    visited.set(valueNumber);
    BitSet outputSet = getOutputSet(valueNumber);
    result.or(outputSet);
    for (int i = outputSet.nextSetBit(0); i >= 0; i = outputSet.nextSetBit(i+1)) {
      if (!visited.get(i)) {
        workList.addLast(i);
      }
    }
  }
  return result;
}

代码示例来源:origin: cmusphinx/sphinx4

/**
 * Makes list of tuples of the given size out of list of words.
 *
 * @param words words
 * @return list of tuples of size {@link #tupleSize}
 */
private List<String> getTuples(List<String> words) {
  List<String> result = new ArrayList<String>();
  LinkedList<String> tuple = new LinkedList<String>();
  
  Iterator<String> it = words.iterator();
  for (int i = 0; i < tupleSize - 1; i++) {
    tuple.add(it.next());
  }
  while (it.hasNext()) {
    tuple.addLast(it.next());
    result.add(Utilities.join(tuple));
    tuple.removeFirst();
  }
  return result;
}

代码示例来源:origin: naman14/Timber

private void cleanUpHistory() {
    if (!mHistoryOfNumbers.isEmpty() && mHistoryOfNumbers.size() >= MAX_HISTORY_SIZE) {
      for (int i = 0; i < Math.max(1, MAX_HISTORY_SIZE / 2); i++) {
        mPreviousNumbers.remove(mHistoryOfNumbers.removeFirst());
      }
    }
  }
}

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

LinkedList<T> queue = new LinkedList<>();
visited.add(o);
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: oracle/opengrok

stack.addLast(g);
while (!stack.isEmpty()) {
  Group g = stack.getFirst();
  stack.removeFirst();

代码示例来源:origin: stackoverflow.com

import java.util.LinkedList;

class Test {
  public static void main(String args[]) {
    char arr[] = {3,1,4,1,5,9,2,6,5,3,5,8,9};
    LinkedList<Integer> fifo = new LinkedList<Integer>();

    for (int i = 0; i < arr.length; i++)
      fifo.add (new Integer (arr[i]));

    System.out.print (fifo.removeFirst() + ".");
    while (! fifo.isEmpty())
      System.out.print (fifo.removeFirst());
    System.out.println();
  }
}

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

if (ll.size() > markovOrder) {
 ll.removeLast();
ll.addLast(t.getChild(0));
if (ll.size() > markovOrder) {
 ll.removeFirst();

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

private Iterator currentIterator()
{
  while ( iteratorStack.size() > 0 )
  {
    Iterator curIter = (Iterator) iteratorStack.getFirst();
    if ( curIter.hasNext() )
    {
      return curIter;
    }
    iteratorStack.removeFirst();
  }
  return null;
}

代码示例来源:origin: oblac/jodd

/**
 * Walks over the child notes, maintaining the tree order and not using recursion.
 */
protected void walkDescendantsIteratively(final LinkedList<Node> nodes, final CssSelector cssSelector, final List<Node> result) {
  while (!nodes.isEmpty()) {
    Node node = nodes.removeFirst();
    selectAndAdd(node, cssSelector, result);
    // append children in walking order to be processed right after this node
    int childCount = node.getChildNodesCount();
    for (int i = childCount - 1; i >= 0; i--) {
      nodes.addFirst(node.getChild(i));
    }
  }
}

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

/**
 * Creates a new iterator representation for all files within a folder.
 *
 * @param folder The root folder.
 */
protected FolderIterator(File folder) {
  files = new LinkedList<File>(Collections.singleton(folder));
  File candidate;
  do {
    candidate = files.removeFirst();
    File[] file = candidate.listFiles();
    if (file != null) {
      files.addAll(0, Arrays.asList(file));
    }
  } while (!files.isEmpty() && (files.peek().isDirectory() || files.peek().equals(new File(folder, JarFile.MANIFEST_NAME))));
}

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

public Thread deQ(Thread t) throws IllegalMonitorStateException {
 if (t != q.getFirst()) {
  throw new IllegalMonitorStateException();
 }
 return q.removeFirst();
}

相关文章

微信公众号

最新文章

更多