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

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

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

Vector.ofAll介绍

[英]Creates a Vector of the given elements.

The resulting vector has the same iteration order as the given iterable of elements if the iteration order of the elements is stable.
[中]创建给定元素的向量。
如果元素的迭代顺序是稳定的,则得到的向量与给定元素的迭代顺序相同。

代码示例

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

@SuppressWarnings("ObjectEquality")
private Vector<T> wrap(BitMappedTrie<T> trie) {
  return (trie == this.trie)
      ? this
      : ofAll(trie);
}

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

@SuppressWarnings("unchecked")
  private static <T> IndexedSeq<T> toIndexedSeq(Iterable<? extends T> iterable) {
    return (iterable instanceof IndexedSeq) ? (IndexedSeq<T>) iterable : Vector.ofAll(iterable);
  }
}

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

/**
 * Creates a Vector that contains the elements of the given {@link java.util.stream.Stream}.
 *
 * @param javaStream A {@link java.util.stream.Stream}
 * @param <T>        Component type of the Stream.
 * @return A Vector containing the given elements in the same order.
 */
public static <T> Vector<T> ofAll(java.util.stream.Stream<? extends T> javaStream) {
  Objects.requireNonNull(javaStream, "javaStream is null");
  return ofAll(Iterator.ofAll(javaStream.iterator()));
}

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

/**
 * Creates a Vector from boolean values.
 *
 * @param elements boolean values
 * @return A new Vector of Boolean values
 * @throws NullPointerException if elements is null
 */
public static Vector<Boolean> ofAll(boolean... elements) {
  Objects.requireNonNull(elements, "elements is null");
  return ofAll(BitMappedTrie.ofAll(elements));
}

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

/**
 * Creates a Vector from float values.
 *
 * @param elements float values
 * @return A new Vector of Float values
 * @throws NullPointerException if elements is null
 */
public static Vector<Float> ofAll(float... elements) {
  Objects.requireNonNull(elements, "elements is null");
  return ofAll(BitMappedTrie.ofAll(elements));
}

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

/**
 * Returns a singleton {@code Vector}, i.e. a {@code Vector} of one element.
 *
 * @param element An element.
 * @param <T>     The component type
 * @return A new Vector instance containing the given element
 */
public static <T> Vector<T> of(T element) {
  return ofAll(Iterator.of(element));
}

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

/**
 * Creates a Vector from byte values.
 *
 * @param elements byte values
 * @return A new Vector of Byte values
 * @throws NullPointerException if elements is null
 */
public static Vector<Byte> ofAll(byte... elements) {
  Objects.requireNonNull(elements, "elements is null");
  return ofAll(BitMappedTrie.ofAll(elements));
}

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

@Override
public Vector<T> orElse(Iterable<? extends T> other) {
  return isEmpty() ? ofAll(other) : this;
}

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

/**
 * Creates a Vector from short values.
 *
 * @param elements short values
 * @return A new Vector of Short values
 * @throws NullPointerException if elements is null
 */
public static Vector<Short> ofAll(short... elements) {
  Objects.requireNonNull(elements, "elements is null");
  return ofAll(BitMappedTrie.ofAll(elements));
}

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

/**
 * Creates a Vector from char values.
 *
 * @param elements char values
 * @return A new Vector of Character values
 * @throws NullPointerException if elements is null
 */
public static Vector<Character> ofAll(char... elements) {
  Objects.requireNonNull(elements, "elements is null");
  return ofAll(BitMappedTrie.ofAll(elements));
}

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

/**
 * Creates a Vector from double values.
 *
 * @param elements double values
 * @return A new Vector of Double values
 * @throws NullPointerException if elements is null
 */
public static Vector<Double> ofAll(double... elements) {
  Objects.requireNonNull(elements, "elements is null");
  return ofAll(BitMappedTrie.ofAll(elements));
}

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

/**
 * Creates a Vector from int values.
 *
 * @param elements int values
 * @return A new Vector of Integer values
 * @throws NullPointerException if elements is null
 */
public static Vector<Integer> ofAll(int... elements) {
  Objects.requireNonNull(elements, "elements is null");
  return ofAll(BitMappedTrie.ofAll(elements));
}

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

/**
 * Creates a Vector from long values.
 *
 * @param elements long values
 * @return A new Vector of Long values
 * @throws NullPointerException if elements is null
 */
public static Vector<Long> ofAll(long... elements) {
  Objects.requireNonNull(elements, "elements is null");
  return ofAll(BitMappedTrie.ofAll(elements));
}

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

@Override
public Tuple2<Vector<T>, Vector<T>> partition(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final ArrayList<T> left = new ArrayList<>(), right = new ArrayList<>();
  for (int i = 0; i < length(); i++) {
    final T t = get(i);
    (predicate.test(t) ? left : right).add(t);
  }
  return Tuple.of(ofAll(left), ofAll(right));
}

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

@Override
public <U, R> Vector<R> zipWith(Iterable<? extends U> that, BiFunction<? super T, ? super U, ? extends R> mapper) {
  Objects.requireNonNull(that, "that is null");
  Objects.requireNonNull(mapper, "mapper is null");
  return ofAll(iterator().zipWith(that, mapper));
}

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

@Override
public <U> Vector<U> zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  return ofAll(iterator().zipWithIndex(mapper));
}

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

@Override
public <U> Vector<U> flatMap(Function<? super T, ? extends Iterable<? extends U>> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  final Iterator<? extends U> results = iterator().flatMap(mapper);
  return ofAll(results);
}

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

@Override
public <U> Vector<Tuple2<T, U>> zipAll(Iterable<? extends U> that, T thisElem, U thatElem) {
  Objects.requireNonNull(that, "that is null");
  return ofAll(iterator().zipAll(that, thisElem, thatElem));
}

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

@Override
public <R> Vector<R> collect(PartialFunction<? super T, ? extends R> partialFunction) {
  return ofAll(iterator().<R> collect(partialFunction));
}

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

@Override
public Vector<T> appendAll(Iterable<? extends T> iterable) {
  Objects.requireNonNull(iterable, "iterable is null");
  if (isEmpty()) {
    return ofAll(iterable);
  }
  if (io.vavr.collection.Collections.isEmpty(iterable)){
    return this;
  }
  return new Vector<>(trie.appendAll(iterable));
}

相关文章