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

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

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

Stream.flatMapToLong介绍

[英]Returns an LongStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is java.util.stream.BaseStream#close() after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

This is an intermediate operation.
[中]

代码示例

代码示例来源:origin: google/guava

/**
 * Returns a {@link LongStream} containing the elements of the first stream, followed by the
 * elements of the second stream, and so on.
 *
 * <p>This is equivalent to {@code Stream.of(streams).flatMapToLong(stream -> stream)}, but the
 * returned stream may perform better.
 *
 * @see LongStream#concat(LongStream, LongStream)
 */
public static LongStream concat(LongStream... streams) {
 // TODO(lowasser): optimize this later
 return Stream.of(streams).flatMapToLong(stream -> stream);
}

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

/**
 * Returns a {@link LongStream} containing the elements of the first stream, followed by the
 * elements of the second stream, and so on.
 *
 * <p>This is equivalent to {@code Stream.of(streams).flatMapToLong(stream -> stream)}, but the
 * returned stream may perform better.
 *
 * @see LongStream#concat(LongStream, LongStream)
 */
public static LongStream concat(LongStream... streams) {
 // TODO(lowasser): optimize this later
 return Stream.of(streams).flatMapToLong(stream -> stream);
}

代码示例来源:origin: google/j2objc

/**
 * Returns a {@link LongStream} containing the elements of the first stream, followed by the
 * elements of the second stream, and so on.
 *
 * <p>This is equivalent to {@code Stream.of(streams).flatMapToLong(stream -> stream)}, but the
 * returned stream may perform better.
 *
 * @see LongStream#concat(LongStream, LongStream)
 */
public static LongStream concat(LongStream... streams) {
 // TODO(lowasser): optimize this later
 return Stream.of(streams).flatMapToLong(stream -> stream);
}

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

/**
 * Returns an {@code LongStream} consisting of the results of replacing each
 * element of this stream with the contents of a mapped stream produced by
 * applying the provided mapping function to each element.  Each mapped
 * stream is {@link java.util.stream.BaseStream#close() closed} after its
 * contents have been placed into this stream.  (If a mapped stream is
 * {@code null} an empty stream is used, instead.)
 * <p>
 * This is an intermediate operation.
 *
 * @param mapper  a non-interfering, stateless function to apply to each 
 *                element which produces a stream of new elements
 * @return        the new stream
 * 
 * @see #flatMap(Function)
 */
@Override
public LongStream flatMapToLong(Function<? super Map.Entry<K, V>, ? extends LongStream> mapper) {
  return inner.flatMapToLong(mapper);
}

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

/**
 * Returns a {@link LongStream} containing the elements of the first stream, followed by the
 * elements of the second stream, and so on.
 *
 * <p>This is equivalent to {@code Stream.of(streams).flatMapToLong(stream -> stream)}, but the
 * returned stream may perform better.
 *
 * @see LongStream#concat(LongStream, LongStream)
 */
public static LongStream concat(LongStream... streams) {
 // TODO(lowasser): optimize this later
 return Stream.of(streams).flatMapToLong(stream -> stream);
}

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

public FlatMapToLongAction(Function<? super T, ? extends LongStream> mapper) {
  super(s -> s.flatMapToLong(requireNonNull(mapper)), LongStream.class, FLAT_MAP_TO);
}

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

/**
 * Will be used when there are too many proc wal files. We will rewrite the states of the active
 * procedures in the oldest proc wal file so that we can delete it.
 * @return all the active procedure ids in this tracker.
 */
public long[] getAllActiveProcIds() {
 return map.values().stream().map(BitSetNode::getActiveProcIds).filter(p -> p.length > 0)
  .flatMapToLong(LongStream::of).toArray();
}

代码示例来源:origin: ben-manes/caffeine

@Override
 public LongStream events() throws IOException {
  return lines().flatMapToLong(line -> {
   String[] array = line.split(" ", 3);
   long startBlock = Long.parseLong(array[0]);
   int sequence = Integer.parseInt(array[1]);
   return LongStream.range(startBlock, startBlock + sequence);
  });
 }
}

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

@Override
public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
  requireNonNull(mapper);
  if (STRICT) {
    return toStream().flatMapToLong(mapper);
  }
  return mapper.apply(element);
}

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

/**
 * Returns an {@code LongStream} consisting of the results of replacing each
 * key-value pair of this stream with the contents of a mapped stream 
 * produced by applying the provided mapping function to each element. Each 
 * mapped stream is {@link java.util.stream.BaseStream#close() closed} after 
 * its contents have been placed into this stream.  (If a mapped stream is
 * {@code null} an empty stream is used, instead.)
 * <p>
 * This is an intermediate operation.
 *
 * @param mapper  a non-interfering, stateless function to apply to each 
 *                key-value pair which produces a stream of new elements
 * @return        the new stream
 * 
 * @see #flatMap(Function)
 */
public LongStream flatMapToLong(BiFunction<? super K, ? super V, ? extends LongStream> mapper) {
  return inner.flatMapToLong(e -> mapper.apply(e.getKey(), e.getValue()));
}

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

@Override
public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
  requireNonNull(mapper);
  return materialize().flatMapToLong(mapper);
}

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

/**
 * Gets a stream of values from a collection of range resources.
 */
public static LongStream rangeValues(Collection<Protos.Resource> resources) {
  checkNotNull(resources);
  return resources.stream()
    .filter(Protos.Resource::hasRanges)
    .flatMap(r -> r.getRanges().getRangeList().stream())
    .flatMapToLong(Utils::rangeValues);
}

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

@Override
  public LongStream build(boolean parallel) {
    return previous().build(parallel).flatMapToLong(mapper);
  }
}

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

@Override
public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
  return wrap(stream().flatMapToLong(mapper));
}

代码示例来源:origin: ben-manes/caffeine

@Override
 public LongStream events() throws IOException {
  return lines().flatMapToLong(line -> {
   String[] array = line.split(",", 5);
   if (array.length <= 4) {
    return LongStream.empty();
   }
   long startBlock = Long.parseLong(array[1]);
   int size = Integer.parseInt(array[2]);
   int sequence = IntMath.divide(size, BLOCK_SIZE, RoundingMode.UP);
   char readWrite = Character.toLowerCase(array[3].charAt(0));
   return (readWrite == 'w')
     ? LongStream.empty()
     : LongStream.range(startBlock, startBlock + sequence);
  });
 }
}

代码示例来源:origin: my2iu/Jinq

@Override
public LongStream flatMapToLong(
   Function<? super T, ? extends LongStream> mapper)
{
 realizeStream();
 return wrappedStream.flatMapToLong(mapper);
}

代码示例来源:origin: aol/cyclops

@Override
public LongStream flatMapToLong(final Function<? super T, ? extends LongStream> mapper) {
  return unwrapStream().flatMapToLong(mapper);
}

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

@Override
public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
  return stream().flatMapToLong(mapper);
}

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

@Override
public LongStream flatMapToLong(
  final Function<? super T, ? extends LongStream> mapper
) {
  return _self.flatMapToLong(mapper);
}

代码示例来源:origin: poetix/protonpack

@Override
public LongStream flatMapToLong(
    Function<? super Entry<K, V>, ? extends LongStream> mapper) {
  return delegate.flatMapToLong(mapper);
}

相关文章