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

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

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

LinkedList.getFirst介绍

[英]Returns the first element in this list.
[中]返回此列表中的第一个元素。

代码示例

代码示例来源:origin: alibaba/nacos

private int peekStatus(LinkedList statusStack) {
  if (statusStack.size() == 0) {
    return -1;
  }
  Integer status = (Integer)statusStack.getFirst();
  return status.intValue();
}

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

public MessageDispatch peek() {
  synchronized (mutex) {
    if (closed || !running || list.isEmpty()) {
      return null;
    }
    return list.getFirst();
  }
}

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

private void printStats() {
  if (snapshotList.size() >= 10) {
    Long[] begin = snapshotList.getFirst();
    Long[] end = snapshotList.getLast();
    final long sendTps = (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
    final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
    System.out.printf("Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d%n",
      sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4]);
  }
}

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

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

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

while (!preTerms.isEmpty() && isPunc(preTerms.getFirst())) {
  newChildren.add(preTerms.getFirst());
  preTerms.removeFirst();
  newChildren.add(newChild);
 while (!preTerms.isEmpty() && isPunc(preTerms.getLast())) {
  temp.addFirst(preTerms.getLast());
  preTerms.removeLast();
while (!newChildren.isEmpty() && isPunc(newChildren.getFirst())) {
 newChildren.removeFirst();
while (!newChildren.isEmpty() && isPunc(newChildren.getLast())) {
 newChildren.removeLast();

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

if (!locs.isEmpty()) {
    if (cand.serializable()) {
      Iterator<GridCacheMvccCandidate> it = locs.descendingIterator();
    GridCacheMvccCandidate first = locs.getFirst();
    for (ListIterator<GridCacheMvccCandidate> it = locs.listIterator(locs.size()); it.hasPrevious(); ) {
      GridCacheMvccCandidate c = it.previous();
  locs.add(cand);
rmts.add(cand);

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

private Packet findSendablePacket(LinkedList<Packet> outgoingQueue,
                 boolean clientTunneledAuthenticationInProgress) {
  synchronized (outgoingQueue) {
    if (outgoingQueue.isEmpty()) {
      return null;
    if (outgoingQueue.getFirst().bb != null // If we've already starting sending the first packet, we better finish
      || !clientTunneledAuthenticationInProgress) {
      return outgoingQueue.getFirst();
        outgoingQueue.add(0, p);
        return p;
      } else {

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

private void finder1(PegCallGraph pcg) {
 Set clinitMethods = pcg.getClinitMethods();
 Iterator it = pcg.iterator();
 while (it.hasNext()) {
  Object head = it.next();
  // breadth first scan
  Set<Object> gray = new HashSet<Object>();
  LinkedList<Object> queue = new LinkedList<Object>();
  queue.add(head);
  while (queue.size() > 0) {
   Object root = queue.getFirst();
   Iterator succsIt = pcg.getSuccsOf(root).iterator();
   while (succsIt.hasNext()) {
    Object succ = succsIt.next();
    if (!gray.contains(succ)) {
     gray.add(succ);
     queue.addLast(succ);
    } else if (clinitMethods.contains(succ)) {
     continue;
    } else {
     multiCalledMethods.add((SootMethod) succ);
    }
   }
   queue.remove(root);
  }
 }
}

代码示例来源:origin: Ramotion/cardslider-android

final boolean isRemoved = ((RecyclerView.LayoutParams)child.getLayoutParams()).isItemRemoved();
if (isRemoved) {
  removed.add(getPosition(child));
final int first = removed.getFirst();
final int last = removed.getLast();
final int right = last == getItemCount() + removed.size() - 1 ? RecyclerView.NO_POSITION : last;

代码示例来源: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: org.apache.poi/poi-ooxml

Segment lastSegment = segments.getLast();
if (lastSegment.end == upperbound - 1) {
  lastSegment.end = upperbound;
  return false;
} else {
  segments.add(new Segment(upperbound, upperbound));
  return true;
Segment firstSegment = segments.getFirst();
if (firstSegment.start == lowerbound + 1) {
  firstSegment.start = lowerbound;

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

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

代码示例来源:origin: aws/aws-sdk-java

ReceiveMessageBatchTask task = finishedTasks.getFirst();
ReceiveMessageResult result = new ReceiveMessageResult();
LinkedList<Message> messages = new LinkedList<Message>();
    messages.add(msg);
    ++numRetrieved;
  } else {
  finishedTasks.removeFirst();

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Copy all entries which are still in untrackedParentFolders and which
 * belong to a path this treewalk has left into untrackedFolders. It is sure
 * that we will not find any tracked files underneath these paths. Therefore
 * these paths definitely belong to untracked folders.
 *
 * @param currentPath
 *            the current path of the treewalk
 */
private void copyUntrackedFolders(String currentPath) {
  String pathToBeSaved = null;
  while (!untrackedParentFolders.isEmpty()
      && !currentPath.startsWith(untrackedParentFolders.getFirst()
          + "/")) //$NON-NLS-1$
    pathToBeSaved = untrackedParentFolders.removeFirst();
  if (pathToBeSaved != null) {
    while (!untrackedFolders.isEmpty()
        && untrackedFolders.getLast().startsWith(pathToBeSaved))
      untrackedFolders.removeLast();
    untrackedFolders.addLast(pathToBeSaved);
  }
}

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

if (stack.isEmpty()) { // first line, root node
  stack.push(matchNode);
  stack.getFirst().addChild(matchNode);
  stack.push(matchNode);
this.rootNode = stack.getLast();

代码示例来源:origin: spring-projects/spring-framework

this.nextBlockSize = targetCapacity - size();
else if (size() == targetCapacity && this.buffers.getFirst().length == targetCapacity) {
  this.buffers.add(data);
  this.index = totalSize;
  this.alreadyBufferedSize = 0;

代码示例来源:origin: spockframework/spock

private void addOrUpdate(LinkedList<EditOperation> ops, EditOperation.Kind kind, int length) {
 if (length == 0) return;
 if (!ops.isEmpty() && ops.getFirst().getKind() == kind)
  ops.getFirst().incLength(length);
 else
  ops.addFirst(new EditOperation(kind, length));
}

代码示例来源:origin: eneim/toro

((RecyclerView.LayoutParams) child.getLayoutParams()).isItemRemoved();
if (isRemoved) {
 removedPositions.add(getPosition(child));
final int last = removedPositions.getLast();
final int first = removedPositions.getFirst();

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

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

相关文章

微信公众号

最新文章

更多