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

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

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

LinkedList.stream介绍

暂无

代码示例

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

@Override
public Stream<Action<?, ?>> stream() {
  return list.stream();
}

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

@Override
public List<String> getMatchedURIs(final boolean decode) {
  final List<String> result;
  if (decode) {
    result = paths.stream().map(PATH_DECODER).collect(Collectors.toList());
  } else {
    result = paths;
  }
  return Collections.unmodifiableList(result);
}

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

@Override
public List<String> getMatchedURIs(final boolean decode) {
  final List<String> result;
  if (decode) {
    result = paths.stream().map(PATH_DECODER).collect(Collectors.toList());
  } else {
    result = paths;
  }
  return Collections.unmodifiableList(result);
}

代码示例来源:origin: pentaho/pentaho-kettle

private ImmutableList<Operation> filterOperations( Predicate<Operation> filter ) {
 ImmutableList.Builder<Operation> builder = ImmutableList.builder();
 operations.stream().filter( filter ).forEach( builder::add );
 return builder.build();
}

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

private int calcGasPricesSize() {
  return blockGasPrices.stream().map(Array::getLength).mapToInt(Integer::intValue).sum();
}

代码示例来源:origin: jooby-project/jooby

private String summary() {
 return summary.stream().collect(Collectors.joining());
}

代码示例来源:origin: twosigma/beakerx

private int lengthOfCoordinates(LinkedList<String> parts, String last) {
 return parts.stream().mapToInt(x -> x.length() + 1).sum() + last.length();
}

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

/**
 * Returns all named entries in the same order their contents
 * appear within the archive.
 *
 * @param name name of the entry.
 * @return the Iterable&lt;ZipEntry&gt; corresponding to the
 * given name
 * @since 1.9.2
 */
public Iterable<ZipEntry> getEntriesInPhysicalOrder(final String name) {
  if (nameMap.containsKey(name)) {
    return nameMap.get(name).stream().sorted(OFFSET_COMPARATOR)
      .collect(Collectors.toList());
  }
  return Collections.emptyList();
}

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

@Override
public QueueStatus queueStatus() {
 int permits = waiterQueue.stream().map(w -> w.acquirePermits).reduce(0, Integer::sum);
 return new QueueStatus(waiterQueue.size(), permits);
}

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

<T> Optional<Mapper<T>> findMapper(GenericType<T> type, Config.Key key) {
  return providers.stream()
      .map(provider -> provider.apply(type))
      .filter(Optional::isPresent)
      .map(Optional::get)
      .findFirst()
      .map(mapper -> castMapper(type, mapper, key))
      .map(Mapper::create);
}

代码示例来源:origin: RichardWarburton/java-8-lambdas-exercises

@GenerateMicroBenchmark
public int serialLinkedList() {
  return linkedList.stream().mapToInt(i -> i).sum();
}

代码示例来源:origin: pentaho/pentaho-kettle

public org.pentaho.di.engine.model.Hop createHop( Operation from, Operation to, String type ) {
 Preconditions.checkArgument( operations.contains( from ), "!operations.contains(from)" );
 Preconditions.checkArgument( operations.contains( to ), "!operations.contains(to)" );
 Preconditions.checkArgument( from != to, "from == to" );
 org.pentaho.di.engine.model.Hop hop = new org.pentaho.di.engine.model.Hop( from, to, type );
 Preconditions.checkState( hops.stream().noneMatch( it -> it.getFrom() == from && it.getTo() == to ),
  "Hop from %s to %s already exists", from, to );
 hops.add( hop );
 return hop;
}

代码示例来源:origin: jooby-project/jooby

private Optional<String> prefixPath(@Nullable String tail) {
 return path.size() == 0
   ? tail == null ? Optional.empty() : Optional.of(Route.normalize(tail))
   : Optional.of(path.stream()
   .collect(Collectors.joining("", "", tail == null
     ? "" : Route.normalize(tail))));
}

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

@Override
public int getNodes() {
  return IntStream.concat(
      IntStream.of(graphHopperStorage.getNodes()-1),
      additionalEdges.stream().flatMapToInt(edge -> IntStream.of(edge.getBaseNode(), edge.getAdjNode())))
      .max().getAsInt()+1;
}

代码示例来源:origin: jooby-project/jooby

@Override public void enterMvcRoute(final FuzzyDocParser.MvcRouteContext ctx) {
 String path = pattern(ctx.annotations);
 List<String> methods = methods(ctx.annotations);
 if (methods.isEmpty() && path == null) {
  // not an mvc method
  return;
 }
 String comment = ctx.doc.getText();
 String pattern =
   prefix.stream().collect(Collectors.joining()) + "/" + Optional.ofNullable(path)
     .orElse("/");
 if (methods.size() == 0) {
  doc.add(doc("get", normalize(pattern), file, summary(), comment));
 } else {
  methods.stream()
    .forEach(method -> doc.add(doc(method, normalize(pattern), file, summary(), comment)));
 }
}

代码示例来源:origin: jooby-project/jooby

@Override public void enterScript(final FuzzyDocParser.ScriptContext ctx) {
 if (ctx.dot == null && !insideRoute()) {
  /**
   * reset prefix when '.' is missing:
   *
   * use("prefix")
   *   .get()
   *
   * vs
   *
   * get("pattern")
   *
   * but ignore dot when route(prefix) is present (kotlin)
   */
  popPrefix();
  popSummary();
 }
 String comment = Optional.ofNullable(ctx.doc).map(it -> it.getText()).orElse("");
 if (ctx.method != null) {
  String method = ctx.method.getText();
  String pattern =
    prefix.stream().collect(Collectors.joining("")) + "/" + Optional.ofNullable(ctx.pattern)
      .map(it -> str(it.getText()))
      .orElse("/");
  doc.add(doc(method, normalize(pattern), file, summary(), comment));
 }
}

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

varyHeaderValue.set(varyValue);
return vhs.stream()
     .map(variantHolder -> variantHolder.v)
     .collect(Collectors.toList());

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

varyHeaderValue.set(varyValue);
return vhs.stream()
     .map(variantHolder -> variantHolder.v)
     .collect(Collectors.toList());

代码示例来源:origin: Netflix/Priam

private void retrieveAndUpdate(final BackupMetadata backupMetadata) {
  // Retrieve the snapshot metadata and then update the date/status.
  LinkedList<BackupMetadata> metadataLinkedList = locate(backupMetadata.getSnapshotDate());
  if (metadataLinkedList == null) {
    logger.error(
        "No previous backupMetaData found. This should not happen. Creating new to ensure app keeps running.");
    metadataLinkedList = new LinkedList<>();
    backupMetadataMap.put(backupMetadata.getSnapshotDate(), metadataLinkedList);
  }
  Optional<BackupMetadata> searchedData =
      metadataLinkedList
          .stream()
          .filter(backupMetadata1 -> backupMetadata.equals(backupMetadata1))
          .findFirst();
  if (!searchedData.isPresent()) {
    metadataLinkedList.addFirst(backupMetadata);
  }
  searchedData.ifPresent(
      backupMetadata1 -> {
        backupMetadata1.setCompleted(backupMetadata.getCompleted());
        backupMetadata1.setStatus(backupMetadata.getStatus());
        backupMetadata1.setCassandraSnapshotSuccess(
            backupMetadata.isCassandraSnapshotSuccess());
        backupMetadata1.setSnapshotLocation(backupMetadata.getSnapshotLocation());
        backupMetadata1.setLastValidated(backupMetadata.getLastValidated());
      });
}

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

/**
 * This seems a little trivial, but we need to guarantee that all Dialects start their sequences on a non-0 value.
 */
@Test
@TestForIssue(jiraKey = "HHH-8814")
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
@SkipForDialect(
    value = SQLServer2012Dialect.class,
    comment = "SQLServer2012Dialect initializes sequence to minimum value (e.g., Long.MIN_VALUE; Hibernate assumes it is uninitialized."
)
public void testStartOfSequence() throws Exception {
  Session s = openSession();
  Transaction tx = s.beginTransaction();
  final Person person = new Person();
  s.persist( person );
  tx.commit();
  s.close();
  assertTrue( person.getId() > 0 );
  assertTrue( sqlStatementInterceptor.getSqlQueries()
            .stream()
            .filter( sql -> sql.contains( "product_sequence" ) )
            .findFirst()
            .isPresent() );
}

相关文章

微信公众号

最新文章

更多