本文整理了Java中io.vavr.collection.List.of()
方法的一些代码示例,展示了List.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.of()
方法的具体详情如下:
包路径:io.vavr.collection.List
类名称:List
方法名:of
[英]Returns a singleton List, i.e. a List of one element.
[中]返回单例列表,即一个元素的列表。
代码示例来源:origin: vavr-io/vavr
/**
* Alias for {@link List#of(Object)}
*
* @param <T> Component type of element.
* @param element An element.
* @return A new {@link List} instance containing the given element
*/
public static <T> List<T> List(T element) {
return List.of(element);
}
代码示例来源:origin: vavr-io/vavr
/**
* Alias for {@link List#of(Object)}
*
* @param <T> Component type of element.
* @param element An element.
* @return A new {@link List} instance containing the given element
*/
public static <T> Seq<T> Seq(T element) {
return List.of(element);
}
代码示例来源:origin: vavr-io/vavr
@Override
public Seq<?> toSeq() {
return List.of(_1, _2, _3, _4, _5);
}
代码示例来源:origin: vavr-io/vavr
@Override
public Seq<?> toSeq() {
return List.of(_1, _2, _3, _4);
}
代码示例来源:origin: vavr-io/vavr
@Override
public Seq<?> toSeq() {
return List.of(_1, _2, _3, _4, _5, _6, _7, _8);
}
代码示例来源:origin: vavr-io/vavr
@Override
public Seq<?> toSeq() {
return List.of(_1, _2);
}
代码示例来源:origin: vavr-io/vavr
@Override
public Seq<?> toSeq() {
return List.of(_1);
}
代码示例来源:origin: vavr-io/vavr
@Override
public Seq<?> toSeq() {
return List.of(_1, _2, _3, _4, _5, _6);
}
代码示例来源:origin: vavr-io/vavr
@Override
public Seq<?> toSeq() {
return List.of(_1, _2, _3, _4, _5, _6, _7);
}
代码示例来源:origin: vavr-io/vavr
/**
* Returns a singleton {@code Queue}, i.e. a {@code Queue} of one element.
*
* @param element An element.
* @param <T> The component type
* @return A new Queue instance containing the given element
*/
public static <T> Queue<T> of(T element) {
return ofAll(io.vavr.collection.List.of(element));
}
代码示例来源:origin: vavr-io/vavr
@SuppressWarnings("unchecked")
public static <T> PriorityQueue<T> of(Comparator<? super T> comparator, T... elements) {
return ofAll(comparator, io.vavr.collection.List.of(elements));
}
代码示例来源:origin: vavr-io/vavr
/**
* Enqueues the given elements. A queue has FIFO order, i.e. the first of the given elements is
* the first which will be retrieved.
*
* @param elements Elements, may be empty
* @return a new {@code Queue} instance, containing the new elements
* @throws NullPointerException if elements is null
*/
@SuppressWarnings("unchecked")
public Q enqueue(T... elements) {
Objects.requireNonNull(elements, "elements is null");
return enqueueAll(List.of(elements));
}
代码示例来源:origin: apache/incubator-pinot
private static List<Field> getClassFields(Class<?> clazz) {
List<Field> fields = List.of(clazz.getDeclaredFields());
// Recursively add all parent fields
while (clazz.getSuperclass() != null) {
clazz = clazz.getSuperclass();
fields = fields.appendAll(Arrays.asList(clazz.getDeclaredFields()));
}
return fields;
}
代码示例来源:origin: vavr-io/vavr
/**
* Returns a new Node containing the given value and having the given children.
*
* @param value A value
* @param children The child nodes, possibly empty
* @param <T> Value type
* @return A new Node instance.
*/
@SuppressWarnings("varargs")
@SafeVarargs
static <T> Node<T> of(T value, Node<T>... children) {
Objects.requireNonNull(children, "children is null");
return new Node<>(value, io.vavr.collection.List.of(children));
}
代码示例来源:origin: vavr-io/vavr
@SuppressWarnings("unchecked")
public static <T extends Comparable<? super T>> PriorityQueue<T> of(T... elements) {
return ofAll(Comparators.naturalComparator(), io.vavr.collection.List.of(elements));
}
代码示例来源:origin: vavr-io/vavr
@Override
default List<T> append(T element) {
return foldRight(of(element), (x, xs) -> xs.prepend(x));
}
代码示例来源:origin: vavr-io/vavr
Node<T> skewLink(Comparator<? super T> comparator, Node<T> left, Node<T> right) {
if (comparator.compare(left.root, root) <= 0 && comparator.compare(left.root, right.root) <= 0) {
return of(left.root, left.rank + 1, appendTo(right.appendTo(left.children)));
} else if (comparator.compare(right.root, root) <= 0) {
return of(right.root, right.rank + 1, appendTo(left.appendTo(right.children)));
} else {
return of(root, left.rank + 1, io.vavr.collection.List.of(left, right));
}
}
代码示例来源:origin: vavr-io/vavr
/**
* Returns a {@link PriorityQueue} containing {@code n} times the given {@code element}
*
* @param <T> Component type of the {@link PriorityQueue}
* @param size The number of elements in the {@link PriorityQueue}
* @param element The element
* @return A {@link PriorityQueue} of size {@code size}, where each element is the given {@code element}.
*/
@GwtIncompatible
@SuppressWarnings("unchecked")
public static <T> PriorityQueue<T> fill(int size, T element) {
final Comparator<? super T> comparator = Comparators.naturalComparator();
return io.vavr.collection.Collections.fillObject(size, element, empty(comparator), values -> ofAll(comparator, io.vavr.collection.List.of(values)));
}
代码示例来源:origin: vavr-io/vavr
static <T> List<List<T>> apply(List<T> elements, int k) {
if (k == 0) {
return List.of(List.empty());
} else {
return elements.zipWithIndex().flatMap(
t -> apply(elements.drop(t._2 + 1), (k - 1)).map(c -> c.prepend(t._1))
);
}
}
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldPassPositiveRandomizationFactor() {
// Given
final Duration duration = Duration.ofMillis(100);
final float multiplier = 1.5f;
final List<Float> correctFactors = List.of(0.0f, 0.25f, 0.5f, 0.75f, 0.1f);
// When
correctFactors.forEach(v -> IntervalFunction.ofRandomized(duration, v));
correctFactors.forEach(v -> IntervalFunction.ofExponentialRandomBackoff(duration, multiplier, v));
}
内容来源于网络,如有侵权,请联系作者删除!