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

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

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

LinkedList.peek介绍

[英]Retrieves, but does not remove, the head (first element) of this list.
[中]检索但不删除此列表的头(第一个元素)。

代码示例

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

/**
 * Return the {@link Entry} currently at the top of the {@link LinkedList} or
 * {@code null} if the {@link LinkedList} is empty.
 */
@Nullable
public Entry peek() {
  return this.state.peek();
}

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

public SubProcess getCurrentSubProcess() {
 return currentSubprocessStack.peek();
}

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

@Override
public T getCurrent() {
  return internalStack.peek();
}

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

@Override
public Object peekMatchedResource() {
  return matchedResources.peek();
}

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

@Override
public Object peekMatchedResource() {
  return matchedResources.peek();
}

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

/**
 * Return the {@link Entry} currently at the top of the {@link LinkedList} or
 * {@code null} if the {@link LinkedList} is empty.
 */
@Nullable
public Entry peek() {
  return this.state.peek();
}

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

@Override
public BaseDanmaku first() {
  if (items != null && !items.isEmpty()) {
    if (mSortType == ST_BY_LIST) {
      return ((LinkedList<BaseDanmaku>) items).peek();
    }
    return ((SortedSet<BaseDanmaku>) items).first();
  }
  return null;
}

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

private static List<Class<?>> getCurrentExtensions() {
 RunContext context = contextStacks.get().peek();
 if (context == null) return Collections.emptyList();
 return context.globalExtensionClasses;
}

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

/**
 * {@inheritDoc}
 */
@SuppressFBWarnings(value = "IT_NO_SUCH_ELEMENT", justification = "Exception is thrown by invoking removeFirst on an empty list.")
public Element next() {
  try {
    return new Element.ForFile(folder, files.removeFirst());
  } finally {
    while (!files.isEmpty() && (files.peek().isDirectory() || files.peek().equals(new File(folder, JarFile.MANIFEST_NAME)))) {
      File folder = files.removeFirst();
      File[] file = folder.listFiles();
      if (file != null) {
        files.addAll(0, Arrays.asList(file));
      }
    }
  }
}

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

@Override
public String getFinalMatchingGroup() {
  final MatchResult mr = matchResults.peek();
  if (mr == null) {
    return null;
  }
  final String finalGroup = mr.group(mr.groupCount());
  // We have found a match but the right hand path pattern did not match anything
  // so just returning an empty string as a final matching group result.
  // Otherwise a non-empty patterns would fail to match the right-hand-path properly.
  // See also PatternWithGroups.match(CharSequence) implementation.
  return finalGroup == null ? "" : finalGroup;
}

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

@Override
public String getFinalMatchingGroup() {
  final MatchResult mr = matchResults.peek();
  if (mr == null) {
    return null;
  }
  final String finalGroup = mr.group(mr.groupCount());
  // We have found a match but the right hand path pattern did not match anything
  // so just returning an empty string as a final matching group result.
  // Otherwise a non-empty patterns would fail to match the right-hand-path properly.
  // See also PatternWithGroups.match(CharSequence) implementation.
  return finalGroup == null ? "" : finalGroup;
}

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

@Override
  public void characters(char ch[], int start, int length) {
    String value = new String(ch, start, length);
    mDataSet.addValue(value, mOpenTags.peek());
  }
}

代码示例来源:origin: TeamNewPipe/NewPipe

public void pushToStack(int serviceId, String videoUrl, String name) {
  if (DEBUG) {
    Log.d(TAG, "pushToStack() called with: serviceId = [" + serviceId + "], videoUrl = [" + videoUrl + "], name = [" + name + "]");
  }
  if (stack.size() > 0 && stack.peek().getServiceId() == serviceId && stack.peek().getUrl().equals(videoUrl)) {
    Log.d(TAG, "pushToStack() called with: serviceId == peek.serviceId = [" + serviceId + "], videoUrl == peek.getUrl = [" + videoUrl + "]");
    return;
  } else {
    Log.d(TAG, "pushToStack() wasn't equal");
  }
  stack.push(new StackItem(serviceId, videoUrl, name));
}

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

@Override
public void epilogue(InputStream is) throws IOException {
  expect(MimeMultipart.class);
  ByteArrayOutputStream epilogue = new ByteArrayOutputStream();
  IOUtils.copy(is, epilogue);
  ((MimeMultipart) stack.peek()).setEpilogue(epilogue.toByteArray());
}

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

@Override
public void pushMatchedRuntimeResource(final RuntimeResource runtimeResource) {
  if (tracingLogger.isLogEnabled(ServerTraceEvent.MATCH_RUNTIME_RESOURCE)) {
    tracingLogger.log(ServerTraceEvent.MATCH_RUNTIME_RESOURCE,
        runtimeResource.getResources().get(0).getPath(),
        runtimeResource.getResources().get(0).getPathPattern().getRegex(),
        matchResults.peek().group()
            .substring(0, matchResults.peek().group().length() - getFinalMatchingGroup().length()),
        matchResults.peek().group());
  }
  this.matchedRuntimeResources.push(runtimeResource);
}

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

@Override
public void pushMatchedRuntimeResource(final RuntimeResource runtimeResource) {
  if (tracingLogger.isLogEnabled(ServerTraceEvent.MATCH_RUNTIME_RESOURCE)) {
    tracingLogger.log(ServerTraceEvent.MATCH_RUNTIME_RESOURCE,
        runtimeResource.getResources().get(0).getPath(),
        runtimeResource.getResources().get(0).getPathPattern().getRegex(),
        matchResults.peek().group()
            .substring(0, matchResults.peek().group().length() - getFinalMatchingGroup().length()),
        matchResults.peek().group());
  }
  this.matchedRuntimeResources.push(runtimeResource);
}

代码示例来源:origin: TeamNewPipe/NewPipe

public void setTitleToUrl(int serviceId, String videoUrl, String name) {
  if (name != null && !name.isEmpty()) {
    for (StackItem stackItem : stack) {
      if (stack.peek().getServiceId() == serviceId
          && stackItem.getUrl().equals(videoUrl)) {
        stackItem.setTitle(name);
      }
    }
  }
}

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

@Override
  public void field(Field parsedField) throws MimeException {
    expect(Part.class);
    String name = parsedField.getName();
    String raw = parsedField.getRaw().toString();
    ((Part) stack.peek()).addRawHeader(name, raw);
  }
}

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

@Override
public void body(BodyDescriptor bd, InputStream in) throws IOException, MimeException {
  expect(Part.class);
  Body body = bodyFactory.createBody(bd.getTransferEncoding(), bd.getMimeType(), in);
  ((Part)stack.peek()).setBody(body);
}

相关文章

微信公众号

最新文章

更多