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

x33g5p2x  于2022-01-16 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(528)

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

Stream.iterator介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

private String columnDefinitions(List<DataTypeTest.Input<?>> inputs)
  {
    List<String> columnTypeDefinitions = inputs.stream()
        .map(DataTypeTest.Input::getInsertType)
        .collect(toList());
    Stream<String> columnDefinitions = range(0, columnTypeDefinitions.size())
        .mapToObj(i -> format("col_%d %s", i, columnTypeDefinitions.get(i)));
    return Joiner.on(",\n").join(columnDefinitions.iterator());
  }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public Iterable<InputFile> filter(Iterable<InputFile> target) {
 return () -> StreamSupport.stream(target.spliterator(), false)
  .filter(this::apply)
  .iterator();
}

代码示例来源:origin: SonarSource/sonarqube

private static void dropColumns(StringBuilder sql, String columnPrefix, String... columnNames) {
 Iterator<String> columnNamesIterator = Arrays.stream(columnNames).iterator();
 while (columnNamesIterator.hasNext()) {
  sql.append(columnPrefix);
  sql.append(columnNamesIterator.next());
  if (columnNamesIterator.hasNext()) {
   sql.append(", ");
  }
 }
}

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

private void files(Path dir, Throwing.Consumer<Path> consumer) throws Exception {
 try (Stream<Path> stream = Files.walk(dir)) {
  Iterator<Path> files = stream.filter(Files::isRegularFile)
    .filter(it -> it.toString().endsWith(".svg"))
    .sorted()
    .iterator();
  while (files.hasNext()) {
   consumer.accept(files.next());
  }
 }
}

代码示例来源:origin: prestodb/presto

private Iterator<InternalHiveSplit> createInternalHiveSplitIterator(Path path, FileSystem fileSystem, InternalHiveSplitFactory splitFactory, boolean splittable)
{
  return Streams.stream(new HiveFileIterator(path, fileSystem, directoryLister, namenodeStats, recursiveDirWalkerEnabled ? RECURSE : IGNORED))
      .map(status -> splitFactory.createInternalHiveSplit(status, splittable))
      .filter(Optional::isPresent)
      .map(Optional::get)
      .iterator();
}

代码示例来源:origin: lettuce-io/lettuce-core

private static List<Integer> readSlots(List<String> slotStrings) {
  List<Integer> slots = new ArrayList<>();
  for (String slotString : slotStrings) {
    if (slotString.startsWith(TOKEN_SLOT_IN_TRANSITION)) {
      // not interesting
      continue;
    }
    if (slotString.contains("-")) {
      // slot range
      Iterator<String> it = DASH_PATTERN.splitAsStream(slotString).iterator();
      int from = Integer.parseInt(it.next());
      int to = Integer.parseInt(it.next());
      for (int slot = from; slot <= to; slot++) {
        slots.add(slot);
      }
      continue;
    }
    slots.add(Integer.parseInt(slotString));
  }
  return Collections.unmodifiableList(slots);
}

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

public void send(Map<Integer, NodeInfo> taskToNode, Map<NodeInfo, IConnection> connections) {
  HashMap<NodeInfo, Stream<TaskMessage>> bundleMapByDestination = groupBundleByDestination(taskToNode);
  for (Map.Entry<NodeInfo, Stream<TaskMessage>> entry : bundleMapByDestination.entrySet()) {
    NodeInfo node = entry.getKey();
    IConnection conn = connections.get(node);
    if (conn != null) {
      Iterator<TaskMessage> iter = entry.getValue().iterator();
      if (iter.hasNext()) {
        conn.send(iter);
      }
    } else {
      LOG.warn("Connection not available for hostPort {}", node);
    }
  }
}

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

count += compile(pipeline, files.stream().filter(styles).iterator(), MediaType.css, css,
  shouldProcess, count, total);
List<File> result = new ArrayList<>(css.getResult());
count += compile(pipeline, files.stream().filter(scripts).iterator(), MediaType.js, js,
  shouldProcess, count, total);
result.addAll(js.getResult());

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

/**
 * Joins each elem in the {@link Stream} with the given glue.
 * For example, given a list of {@code Integers}, you can create
 * a comma-separated list by calling {@code join(numbers, ", ")}.
 *
 * @see StringUtils#join(Iterable, String)
 */
public static <X> String join(Stream<X> l, String glue) {
 StringBuilder sb = new StringBuilder();
 boolean first = true;
 Iterator<X> iter = l.iterator();
 while (iter.hasNext()) {
  if ( ! first) {
   sb.append(glue);
  } else {
   first = false;
  }
  sb.append(iter.next());
 }
 return sb.toString();
}

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

MultiCriteriaLabelSetting stationRouter = new MultiCriteriaLabelSetting(accessEgressGraphExplorer, flagEncoder, reverse, maxWalkDistancePerLeg, false, false, false, maxVisitedNodesForRequest, new ArrayList<>());
stationRouter.setBetaWalkTime(betaWalkTime);
Iterator<Label> stationIterator = stationRouter.calcLabels(destNode, startNode, initialTime, blockedRouteTypes).iterator();
List<Label> stationLabels = new ArrayList<>();
while (stationIterator.hasNext()) {
  Label label = stationIterator.next();
  if (label.adjNode == startNode) {
    stationLabels.add(label);
  smallestStationLabelWeight = Long.MAX_VALUE;
Iterator<Label> iterator = router.calcLabels(startNode, destNode, initialTime, blockedRouteTypes).iterator();
Map<Label, Label> originalSolutions = new HashMap<>();
          highestWeightForDominationTest = router.weight(discoveredSolutions.get(discoveredSolutions.size()-1));
        } else {
          highestWeightForDominationTest = discoveredSolutions.stream().filter(s -> !s.impossible && (ignoreTransfers || s.nTransfers <= 1)).mapToLong(router::weight).min().orElse(Long.MAX_VALUE);
    .map(originalSolutions::get)
    .map(l -> new TripFromLabel(gtfsStorage, realtimeFeed).getTransitions(arriveBy, flagEncoder, graphExplorer, l)).collect(Collectors.toList());
List<List<Label.Transition>> paths = pathsToStations.stream().map(p -> {
  if (arriveBy) {
    List<Label.Transition> pp = new ArrayList<>(p.subList(1, p.size()));

代码示例来源:origin: MovingBlocks/Terasology

@SafeVarargs
@Override
public final Iterable<EntityRef> getEntitiesWith(Class<? extends Component>... componentClasses) {
  return () -> entityStore.keySet().stream()
      //Keep entities which have all of the required components
      .filter(id -> Arrays.stream(componentClasses)
          .allMatch(component -> componentStore.get(id, component) != null))
      .map(id -> getEntity(id))
      .iterator();
}

代码示例来源:origin: reactor/reactor-core

@SuppressWarnings("unchecked")
void assertInnerSubscriberBefore(FluxZip.ZipCoordinator c) {
  FluxZip.ZipInner s = (FluxZip.ZipInner) c.inners()
                       .iterator()
                       .next();
  assertThat(s.scan(Scannable.Attr.TERMINATED)).isFalse();
  assertThat(s.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
  assertThat(s.scan(Scannable.Attr.BUFFERED)).isEqualTo(0);
  assertThat(s.scan(Scannable.Attr.CANCELLED)).isFalse();
}

代码示例来源:origin: prestodb/presto

static String formatSortItems(List<SortItem> sortItems, Optional<List<Expression>> parameters)
{
  return Joiner.on(", ").join(sortItems.stream()
      .map(sortItemFormatterFunction(parameters))
      .iterator());
}

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

public JrtfsCodeBaseIterator() {
  try {
    iterator = Files.walk(root).filter(p -> isClassFile(p)).iterator();
  } catch (IOException e) {
    e.printStackTrace();
  }
}

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

public Stream<String> searchAllLogs(Pattern pattern, Function<Matcher, String> matchProcessor) throws IOException {
    final List<String> matches = new ArrayList<>(2);

    try (Stream<Path> logFilesStream = Files.list(log)) {
      final Iterator<Path> logFiles = logFilesStream.iterator();
      while (logFiles.hasNext()) {
        final Path logFile = logFiles.next();
        if (!logFile.getFileName().toString().endsWith(".log")) {
          // ignore logs for previous runs that have a number suffix
          continue;
        }
        try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(logFile.toFile()), StandardCharsets.UTF_8))) {
          String line;
          while ((line = br.readLine()) != null) {
            Matcher matcher = pattern.matcher(line);
            if (matcher.matches()) {
              matches.add(matchProcessor.apply(matcher));
            }
          }
        }
      }
    }
    return matches.stream();
  }
}

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

private Stream<TransferWithTime> getType0TransferWithTimes(GTFSFeed gtfsFeed) {
  return gtfsFeed.transfers.entrySet()
      .parallelStream()
      .filter(e -> e.getValue().transfer_type == 0)
      .map(e -> {
        PointList points = new PointList(2, false);
        final int fromnode = gtfsStorage.getStationNodes().get(e.getValue().from_stop_id);
        Iterator<Label> iterator = router.calcLabels(fromnode, tonode, Instant.ofEpochMilli(0), 0).iterator();
        Label solution = null;
        while (iterator.hasNext()) {
          Label label = iterator.next();
          if (tonode == label.adjNode) {
            solution = label;

代码示例来源:origin: prestodb/presto

private Iterator<LocatedFileStatus> statusFromObjects(List<S3ObjectSummary> objects)
{
  // NOTE: for encrypted objects, S3ObjectSummary.size() used below is NOT correct,
  // however, to get the correct size we'd need to make an additional request to get
  // user metadata, and in this case it doesn't matter.
  return objects.stream()
      .filter(object -> !object.getKey().endsWith(PATH_SEPARATOR))
      .map(object -> new FileStatus(
          object.getSize(),
          false,
          1,
          BLOCK_SIZE.toBytes(),
          object.getLastModified().getTime(),
          qualifiedPath(new Path(PATH_SEPARATOR + object.getKey()))))
      .map(this::createLocatedFileStatus)
      .iterator();
}

代码示例来源:origin: reactor/reactor-core

@SuppressWarnings("unchecked")
void assertInnerSubscriber(FluxZip.ZipCoordinator c) {
  FluxZip.ZipInner s = (FluxZip.ZipInner) c.inners()
                       .iterator()
                       .next();
  assertThat(s.scan(Scannable.Attr.TERMINATED)).isFalse();
  assertThat(s.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
  assertThat(c.inners()).hasSize(3);
  assertThat(s.scan(Scannable.Attr.CANCELLED)).isTrue();
}

代码示例来源:origin: prestodb/presto

private String joinExpressions(List<Expression> expressions)
  {
    return Joiner.on(", ").join(expressions.stream()
        .map((e) -> process(e, null))
        .iterator());
  }
}

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

.range(1, splits.size() - 3)
   .mapToObj(dataSourceDelimiterOrder -> DELIMITER_JOINER.join(splits.subList(0, dataSourceDelimiterOrder)))
   .filter(dataSource -> dataSource.length() != probableDataSource.length())
   .flatMap(dataSource -> iteratePossibleParsingsWithDataSource(dataSource, segmentId).stream())
   .iterator();
 return Iterables.concat(probableParsings, otherPossibleParsings);
} else {
   })
   .flatMap(List::stream)
   .iterator();

相关文章