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

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

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

LinkedList.peekFirst介绍

[英]Retrieves, but does not remove, the first element of this list, or returns null if this list is empty.
[中]检索但不删除此列表的第一个元素,如果此列表为空,则返回null。

代码示例

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

public TopologyDetails getNextHighest() {
  return tds.peekFirst();
}

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

public static Z z() {
  return instances2.get().peekFirst();
}

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

public E peekFirst() {
 lock.lock();
 try {
  return list.size() == 0 ? null : list.peekFirst();
 } finally {
  lock.unlock();
 }
}

代码示例来源:origin: Bilibili/DanmakuFlameMaster

private synchronized long getAverageRenderingTime() {
  int frames = mDrawTimes.size();
  if(frames <= 0)
    return 0;
  Long first = mDrawTimes.peekFirst();
  Long last = mDrawTimes.peekLast();
  if (first == null || last == null) {
    return 0;
  }
  long dtime = last - first;
  return dtime / frames;
}

代码示例来源:origin: Bilibili/DanmakuFlameMaster

private float fps() {
  long lastTime = SystemClock.uptimeMillis();
  mDrawTimes.addLast(lastTime);
  Long first = mDrawTimes.peekFirst();
  if (first == null) {
    return 0.0f;
  }
  float dtime = lastTime - first;
  int frames = mDrawTimes.size();
  if (frames > MAX_RECORD_SIZE) {
    mDrawTimes.removeFirst();
  }
  return dtime > 0 ? mDrawTimes.size() * ONE_SECOND / dtime : 0.0f;
}

代码示例来源:origin: Bilibili/DanmakuFlameMaster

private float fps() {
  long lastTime = SystemClock.uptimeMillis();
  mDrawTimes.addLast(lastTime);
  Long first = mDrawTimes.peekFirst();
  if (first == null) {
    return 0.0f;
  }
  float dtime = lastTime - first;
  int frames = mDrawTimes.size();
  if (frames > MAX_RECORD_SIZE) {
    mDrawTimes.removeFirst();
  }
  return dtime > 0 ? mDrawTimes.size() * ONE_SECOND / dtime : 0.0f;
}
@Override

代码示例来源:origin: Bilibili/DanmakuFlameMaster

private float fps() {
  long lastTime = SystemClock.uptimeMillis();
  mDrawTimes.addLast(lastTime);
  Long first = mDrawTimes.peekFirst();
  if (first == null) {
    return 0.0f;
  }
  float dtime = lastTime - first;
  int frames = mDrawTimes.size();
  if (frames > MAX_RECORD_SIZE) {
    mDrawTimes.removeFirst();
  }
  return dtime > 0 ? mDrawTimes.size() * ONE_SECOND / dtime : 0.0f;
}
@Override

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

if (this.buffers.peekFirst() == null) {
  this.nextBlockSize = targetCapacity - size();

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

@Override
public DomainEventMessage<?> peek() {
  if (!hasNext()) {
    return null;
  }
  return streams.peekFirst().peek();
}

代码示例来源:origin: weibocom/motan

char curr = result1.charAt(i++);
support(curr);
char prev = sub.peekFirst();
if (prev != '#') {
  supportFollowing(prev, curr);
  case ')':
    outer.removeFirst();
    outer.peekFirst().push(evalWithinParentheses(sub));
    sub = outer.peekFirst();
    break;
  default:

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

if (this.buffers.peekFirst() == null) {
  this.nextBlockSize = targetCapacity - size();

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

public Iterator<Proposal> getProposalsFromTxnLog(long peerZxid,
    long limit) {
  if (peerZxid >= txnLog.peekFirst().packet.getZxid()) {
    return txnLog.iterator();
  } else {
    return (new LinkedList<Proposal>()).iterator();
  }
}

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

@Override
public DomainEventMessage<?> next() {
  if (!hasNext()) {
    return null;
  }
  DomainEventMessage<?> next = streams.peekFirst().next();
  lastSequenceNumber = next.getSequenceNumber();
  return next;
}

代码示例来源:origin: udacity/ud851-Exercises

/**
 * This draw method abstracts out what is common between drawing all shapes
 *
 * @param canvas         The canvas to draw on
 * @param currentFreqAve The average frequency for the same, which determines the boost in size
 * @param currentAngle   The current angle around the center to draw the shape
 */
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
  float currentSize = sMinSize + mMultiplier * currentFreqAve;
  // Calculate where the shape is
  float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
  float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
  // Calculate where the next point in the trail is
  float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  mTrailPath.rewind(); // clear the trail
  mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
  // Keep the trail size correct
  while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
    mTrailList.poll();
  }
  // Draw the trail
  mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
  for (TrailPoint trailPoint : mTrailList) {
    mTrailPath.lineTo(trailPoint.x, trailPoint.y);
  }
  canvas.drawPath(mTrailPath, mTrailPaint);
  // Call the abstract drawThisShape method, this must be defined for each shape.
  drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}

代码示例来源:origin: udacity/ud851-Exercises

/**
 * This draw method abstracts out what is common between drawing all shapes
 *
 * @param canvas         The canvas to draw on
 * @param currentFreqAve The average frequency for the same, which determines the boost in size
 * @param currentAngle   The current angle around the center to draw the shape
 */
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
  float currentSize = sMinSize + mMultiplier * currentFreqAve;
  // Calculate where the shape is
  float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
  float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
  // Calculate where the next point in the trail is
  float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  mTrailPath.rewind(); // clear the trail
  mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
  // Keep the trail size correct
  while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
    mTrailList.poll();
  }
  // Draw the trail
  mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
  for (TrailPoint trailPoint : mTrailList) {
    mTrailPath.lineTo(trailPoint.x, trailPoint.y);
  }
  canvas.drawPath(mTrailPath, mTrailPaint);
  // Call the abstract drawThisShape method, this must be defined for each shape.
  drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}

代码示例来源:origin: udacity/ud851-Exercises

/**
 * This draw method abstracts out what is common between drawing all shapes
 *
 * @param canvas         The canvas to draw on
 * @param currentFreqAve The average frequency for the same, which determines the boost in size
 * @param currentAngle   The current angle around the center to draw the shape
 */
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
  float currentSize = sMinSize + mMultiplier * currentFreqAve;
  // Calculate where the shape is
  float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
  float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
  // Calculate where the next point in the trail is
  float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  mTrailPath.rewind(); // clear the trail
  mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
  // Keep the trail size correct
  while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
    mTrailList.poll();
  }
  // Draw the trail
  mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
  for (TrailPoint trailPoint : mTrailList) {
    mTrailPath.lineTo(trailPoint.x, trailPoint.y);
  }
  canvas.drawPath(mTrailPath, mTrailPaint);
  // Call the abstract drawThisShape method, this must be defined for each shape.
  drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}

代码示例来源:origin: udacity/ud851-Exercises

/**
 * This draw method abstracts out what is common between drawing all shapes
 *
 * @param canvas         The canvas to draw on
 * @param currentFreqAve The average frequency for the same, which determines the boost in size
 * @param currentAngle   The current angle around the center to draw the shape
 */
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
  float currentSize = sMinSize + mMultiplier * currentFreqAve;
  // Calculate where the shape is
  float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
  float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
  // Calculate where the next point in the trail is
  float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  mTrailPath.rewind(); // clear the trail
  mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
  // Keep the trail size correct
  while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
    mTrailList.poll();
  }
  // Draw the trail
  mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
  for (TrailPoint trailPoint : mTrailList) {
    mTrailPath.lineTo(trailPoint.x, trailPoint.y);
  }
  canvas.drawPath(mTrailPath, mTrailPaint);
  // Call the abstract drawThisShape method, this must be defined for each shape.
  drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}

代码示例来源:origin: udacity/ud851-Exercises

/**
 * This draw method abstracts out what is common between drawing all shapes
 *
 * @param canvas         The canvas to draw on
 * @param currentFreqAve The average frequency for the same, which determines the boost in size
 * @param currentAngle   The current angle around the center to draw the shape
 */
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
  float currentSize = sMinSize + mMultiplier * currentFreqAve;
  // Calculate where the shape is
  float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
  float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
  // Calculate where the next point in the trail is
  float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
  mTrailPath.rewind(); // clear the trail
  mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
  // Keep the trail size correct
  while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
    mTrailList.poll();
  }
  // Draw the trail
  mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
  for (TrailPoint trailPoint : mTrailList) {
    mTrailPath.lineTo(trailPoint.x, trailPoint.y);
  }
  canvas.drawPath(mTrailPath, mTrailPaint);
  // Call the abstract drawThisShape method, this must be defined for each shape.
  drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}

代码示例来源:origin: medcl/elasticsearch-analysis-ik

Lexeme nextLexeme = this.results.peekFirst();
boolean appendOk = false;
if(Lexeme.TYPE_CNUM == nextLexeme.getLexemeType()){
Lexeme nextLexeme = this.results.peekFirst();
boolean appendOk = false;
 if(Lexeme.TYPE_COUNT == nextLexeme.getLexemeType()){

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

private CacheGetResult convertCacheGetResult(CacheGetResult originResult) {
  try {
    CacheValueHolder originHolder = (CacheValueHolder) getHolder.invoke(originResult);
    LinkedList<CacheValueHolder> list = new LinkedList<>();
    while (originHolder != null) {
      CacheValueHolder h = new CacheValueHolder();
      if (list.size() > 0) {
        list.getLast().setValue(h);
      }
      list.add(h);
      h.setAccessTime(originHolder.getAccessTime());
      h.setExpireTime(originHolder.getExpireTime());
      Object v = originHolder.getValue();
      if (v != null && !(v instanceof CacheValueHolder)) {
        h.setValue(config.getValueDecoder().apply((byte[]) v));
        break;
      } else if (originHolder.getValue() == null) {
        originHolder = (CacheValueHolder) originHolder.getValue();
      }
    }
    return new CacheGetResult(originResult.getResultCode(), originResult.getMessage(), list.peekFirst());
  } catch (Exception e) {
    throw new CacheException(e);
  }
}

相关文章

微信公众号

最新文章

更多