本文整理了Java中io.vavr.collection.HashSet.ofAll()
方法的一些代码示例,展示了HashSet.ofAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashSet.ofAll()
方法的具体详情如下:
包路径:io.vavr.collection.HashSet
类名称:HashSet
方法名:ofAll
[英]Creates a HashSet of the given elements.
[中]创建给定元素的哈希集。
代码示例来源:origin: vavr-io/vavr
/**
* Creates a HashSet 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 HashSet containing the given elements in the same order.
*/
public static <T> HashSet<T> ofAll(java.util.stream.Stream<? extends T> javaStream) {
Objects.requireNonNull(javaStream, "javaStream is null");
return HashSet.ofAll(Iterator.ofAll(javaStream.iterator()));
}
代码示例来源:origin: vavr-io/vavr
/**
* Creates a HashSet from float values.
*
* @param elements float values
* @return A new HashSet of Float values
* @throws NullPointerException if elements is null
*/
public static HashSet<Float> ofAll(float... elements) {
Objects.requireNonNull(elements, "elements is null");
return HashSet.ofAll(Iterator.ofAll(elements));
}
代码示例来源:origin: vavr-io/vavr
@Override
public <T1, T2, T3> Tuple3<HashSet<T1>, HashSet<T2>, HashSet<T3>> unzip3(
Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) {
Objects.requireNonNull(unzipper, "unzipper is null");
final Tuple3<Iterator<T1>, Iterator<T2>, Iterator<T3>> t = iterator().unzip3(unzipper);
return Tuple.of(HashSet.ofAll(t._1), HashSet.ofAll(t._2), HashSet.ofAll(t._3));
}
代码示例来源:origin: vavr-io/vavr
/**
* Creates a HashSet from byte values.
*
* @param elements byte values
* @return A new HashSet of Byte values
* @throws NullPointerException if elements is null
*/
public static HashSet<Byte> ofAll(byte... elements) {
Objects.requireNonNull(elements, "elements is null");
return HashSet.ofAll(Iterator.ofAll(elements));
}
代码示例来源:origin: vavr-io/vavr
/**
* Creates a HashSet from double values.
*
* @param elements double values
* @return A new HashSet of Double values
* @throws NullPointerException if elements is null
*/
public static HashSet<Double> ofAll(double... elements) {
Objects.requireNonNull(elements, "elements is null");
return HashSet.ofAll(Iterator.ofAll(elements));
}
代码示例来源:origin: vavr-io/vavr
/**
* Creates a HashSet from short values.
*
* @param elements short values
* @return A new HashSet of Short values
* @throws NullPointerException if elements is null
*/
public static HashSet<Short> ofAll(short... elements) {
Objects.requireNonNull(elements, "elements is null");
return HashSet.ofAll(Iterator.ofAll(elements));
}
代码示例来源:origin: vavr-io/vavr
/**
* Creates a HashSet from int values.
*
* @param elements int values
* @return A new HashSet of Integer values
* @throws NullPointerException if elements is null
*/
public static HashSet<Integer> ofAll(int... elements) {
Objects.requireNonNull(elements, "elements is null");
return HashSet.ofAll(Iterator.ofAll(elements));
}
代码示例来源:origin: vavr-io/vavr
@Override
public Tuple2<HashSet<T>, HashSet<T>> partition(Predicate<? super T> predicate) {
Objects.requireNonNull(predicate, "predicate is null");
final Tuple2<Iterator<T>, Iterator<T>> p = iterator().partition(predicate);
return Tuple.of(HashSet.ofAll(p._1), HashSet.ofAll(p._2));
}
代码示例来源:origin: vavr-io/vavr
@Override
public Tuple2<HashSet<T>, HashSet<T>> span(Predicate<? super T> predicate) {
Objects.requireNonNull(predicate, "predicate is null");
final Tuple2<Iterator<T>, Iterator<T>> t = iterator().span(predicate);
return Tuple.of(HashSet.ofAll(t._1), HashSet.ofAll(t._2));
}
代码示例来源:origin: vavr-io/vavr
@Override
public <U> HashSet<T> distinctBy(Function<? super T, ? extends U> keyExtractor) {
Objects.requireNonNull(keyExtractor, "keyExtractor is null");
return HashSet.ofAll(iterator().distinctBy(keyExtractor));
}
代码示例来源:origin: vavr-io/vavr
@Override
public HashSet<T> distinctBy(Comparator<? super T> comparator) {
Objects.requireNonNull(comparator, "comparator is null");
return HashSet.ofAll(iterator().distinctBy(comparator));
}
代码示例来源:origin: vavr-io/vavr
@SuppressWarnings("unchecked")
static <C extends Traversable<T>, T> C retainAll(C source, Iterable<? extends T> elements) {
Objects.requireNonNull(elements, "elements is null");
if (source.isEmpty()) {
return source;
} else {
final Set<T> retained = HashSet.ofAll(elements);
return (C) source.filter(retained::contains);
}
}
代码示例来源:origin: vavr-io/vavr
@Override
public <U> HashSet<Tuple2<T, U>> zipAll(Iterable<? extends U> that, T thisElem, U thatElem) {
Objects.requireNonNull(that, "that is null");
return HashSet.ofAll(iterator().zipAll(that, thisElem, thatElem));
}
代码示例来源:origin: vavr-io/vavr
@Override
public HashSet<T> drop(int n) {
if (n <= 0) {
return this;
} else {
return HashSet.ofAll(iterator().drop(n));
}
}
代码示例来源:origin: vavr-io/vavr
@GwtIncompatible
public static HashSet<Double> rangeClosedBy(double from, double toInclusive, double step) {
return HashSet.ofAll(Iterator.rangeClosedBy(from, toInclusive, step));
}
代码示例来源:origin: vavr-io/vavr
@SuppressWarnings("unchecked")
static <C extends Traversable<T>, T> C removeAll(C source, Iterable<? extends T> elements) {
Objects.requireNonNull(elements, "elements is null");
if (source.isEmpty()) {
return source;
} else {
final Set<T> removed = HashSet.ofAll(elements);
return removed.isEmpty() ? source : (C) source.filter(e -> !removed.contains(e));
}
}
代码示例来源:origin: vavr-io/vavr
@Override
public HashSet<T> dropWhile(Predicate<? super T> predicate) {
Objects.requireNonNull(predicate, "predicate is null");
final HashSet<T> dropped = HashSet.ofAll(iterator().dropWhile(predicate));
return dropped.length() == length() ? this : dropped;
}
代码示例来源:origin: vavr-io/vavr
@Override
public HashSet<T> takeWhile(Predicate<? super T> predicate) {
Objects.requireNonNull(predicate, "predicate is null");
final HashSet<T> taken = HashSet.ofAll(iterator().takeWhile(predicate));
return taken.length() == length() ? this : taken;
}
代码示例来源:origin: vavr-io/vavr
@Override
public HashSet<T> filter(Predicate<? super T> predicate) {
Objects.requireNonNull(predicate, "predicate is null");
final HashSet<T> filtered = HashSet.ofAll(iterator().filter(predicate));
if (filtered.isEmpty()) {
return empty();
} else if (filtered.length() == length()) {
return this;
} else {
return filtered;
}
}
代码示例来源:origin: vavr-io/vavr
@Override
public HashSet<T> take(int n) {
if (n >= size() || isEmpty()) {
return this;
} else if (n <= 0) {
return empty();
} else {
return ofAll(() -> iterator().take(n));
}
}
内容来源于网络,如有侵权,请联系作者删除!