io.vavr.collection.Vector.map()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(102)

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

Vector.map介绍

暂无

代码示例

代码示例来源:origin: vavr-io/vavr

@Override
public IndexedSeq<CharSeq> combinations() {
  return Vector.rangeClosed(0, length()).map(this::combinations).flatMap(Function.identity());
}

代码示例来源:origin: vavr-io/vavr

/**
 * Reduces many {@code Lazy} values into a single {@code Lazy} by transforming an
 * {@code Iterable<Lazy<? extends T>>} into a {@code Lazy<Seq<T>>}.
 *
 * @param <T>    Type of the lazy values.
 * @param values An iterable of lazy values.
 * @return A lazy sequence of values.
 * @throws NullPointerException if values is null
 */
@SuppressWarnings("Convert2MethodRef") // TODO should be fixed in JDK 9 and Idea
public static <T> Lazy<Seq<T>> sequence(Iterable<? extends Lazy<? extends T>> values) {
  Objects.requireNonNull(values, "values is null");
  return Lazy.of(() -> Vector.ofAll(values).map(lazy -> lazy.get()));
}

代码示例来源:origin: vavr-io/vavr

@Override
public Vector<Vector<T>> combinations() { return rangeClosed(0, length()).map(this::combinations).flatMap(Function.identity()); }

代码示例来源:origin: vavr-io/vavr

/**
 * Chooses one of the given generators according to their frequency.
 * Only generators with positive frequencies ares used in returned
 * generator.
 *
 * @param generators A non-empty traversable of Tuples (frequency, generator)
 * @param <T>        Type to be generated
 * @return A new T generator
 * @throws java.lang.NullPointerException     if generators is null
 * @throws java.lang.IllegalArgumentException if generators doesn't contain any generator with positive frequency
 */
static <T> Gen<T> frequency(Iterable<Tuple2<Integer, Gen<T>>> generators) {
  Objects.requireNonNull(generators, "generators is null");
  final Vector<Tuple2<Integer, Gen<T>>> filtered = Iterator.ofAll(generators)
      .filter(t -> t._1() > 0).toVector();
  if (filtered.isEmpty()) {
    throw new IllegalArgumentException("no generator with positive weight");
  }
  final int size = filtered.map(t -> t._1).sum().intValue();
  return choose(1, size).flatMap(n -> GenModule.frequency(n, filtered.iterator()));
}

代码示例来源:origin: vavr-io/vavr

static <T> Vector<Vector<T>> apply(Vector<T> elements, int k) {
    return (k == 0)
        ? Vector.of(Vector.empty())
        : elements.zipWithIndex().flatMap(
        t -> apply(elements.drop(t._2 + 1), (k - 1)).map((Vector<T> c) -> c.prepend(t._1)));
  }
}

代码示例来源:origin: martincooper/java-datatable

/**
 * Map implementation for the DataRowCollection class.
 *
 * @param <U> Mapped return type.
 * @param mapper The map function.
 * @return Returns a sequence of the applied map.
 */
public <U> Seq<U> map(Function<? super DataRow, ? extends U> mapper) {
  return this.rows.map(mapper);
}

代码示例来源:origin: martincooper/java-datatable

/**
 * Map implementation for the DataColumnCollection class.
 *
 * @param <U> Mapped return type.
 * @param mapper The map function.
 * @return Returns a sequence of the applied map.
 */
public <U> Seq<U> map(Function<? super IDataColumn, ? extends U> mapper) {
  return this.columns.map(mapper);
}

代码示例来源:origin: Romeh/spring-boot-akka-event-sourcing-starter

/**
 * Wraps the given event in a Tagged object, instructing the journal to add a tag to it.
 */
private Iterable<Tagged> tagged(Iterable<E> event) {
  return Vector.ofAll(event).map(this::tagged);
}

代码示例来源:origin: io.vavr/vavr

@Override
public IndexedSeq<CharSeq> combinations() {
  return Vector.rangeClosed(0, length()).map(this::combinations).flatMap(Function.identity());
}

代码示例来源:origin: io.vavr/vavr

/**
 * Reduces many {@code Lazy} values into a single {@code Lazy} by transforming an
 * {@code Iterable<Lazy<? extends T>>} into a {@code Lazy<Seq<T>>}.
 *
 * @param <T>    Type of the lazy values.
 * @param values An iterable of lazy values.
 * @return A lazy sequence of values.
 * @throws NullPointerException if values is null
 */
@SuppressWarnings("Convert2MethodRef") // TODO should be fixed in JDK 9 and Idea
public static <T> Lazy<Seq<T>> sequence(Iterable<? extends Lazy<? extends T>> values) {
  Objects.requireNonNull(values, "values is null");
  return Lazy.of(() -> Vector.ofAll(values).map(lazy -> lazy.get()));
}

代码示例来源:origin: io.vavr/vavr

@Override
public Vector<Vector<T>> combinations() { return rangeClosed(0, length()).map(this::combinations).flatMap(Function.identity()); }

代码示例来源:origin: io.vavr/vavr

static <T> Vector<Vector<T>> apply(Vector<T> elements, int k) {
    return (k == 0)
        ? Vector.of(Vector.empty())
        : elements.zipWithIndex().flatMap(
        t -> apply(elements.drop(t._2 + 1), (k - 1)).map((Vector<T> c) -> c.prepend(t._1)));
  }
}

相关文章