io.vavr.Tuple.of()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(116)

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

Tuple.of介绍

[英]Creates a tuple of one element.
[中]创建一个元素的元组。

代码示例

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

/**
 * Append a value to this tuple.
 *
 * @param <T5> type of the value to append
 * @param t5 the value to append
 * @return a new Tuple with the value appended
 */
public <T5> Tuple5<T1, T2, T3, T4, T5> append(T5 t5) {
  return Tuple.of(_1, _2, _3, _4, t5);
}

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

/**
 * Append a value to this tuple.
 *
 * @param <T1> type of the value to append
 * @param t1 the value to append
 * @return a new Tuple with the value appended
 */
public <T1> Tuple1<T1> append(T1 t1) {
  return Tuple.of(t1);
}

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

/**
 * Append a value to this tuple.
 *
 * @param <T6> type of the value to append
 * @param t6 the value to append
 * @return a new Tuple with the value appended
 */
public <T6> Tuple6<T1, T2, T3, T4, T5, T6> append(T6 t6) {
  return Tuple.of(_1, _2, _3, _4, _5, t6);
}

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

/**
 * Append a value to this tuple.
 *
 * @param <T4> type of the value to append
 * @param t4 the value to append
 * @return a new Tuple with the value appended
 */
public <T4> Tuple4<T1, T2, T3, T4> append(T4 t4) {
  return Tuple.of(_1, _2, _3, t4);
}

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

/**
 * Concat a tuple's values to this tuple.
 *
 * @param <T4> the type of the 4th value in the tuple
 * @param tuple the tuple to concat
 * @return a new Tuple with the tuple values appended
 * @throws NullPointerException if {@code tuple} is null
 */
public <T4> Tuple4<T1, T2, T3, T4> concat(Tuple1<T4> tuple) {
  Objects.requireNonNull(tuple, "tuple is null");
  return Tuple.of(_1, _2, _3, tuple._1);
}

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

private static <T> Tuple2<? extends RedBlackTree<T>, Boolean> blackify(RedBlackTree<T> tree) {
  if (tree instanceof Node) {
    final Node<T> node = (Node<T>) tree;
    if (node.color == RED) {
      return Tuple.of(node.color(BLACK), false);
    }
  }
  return Tuple.of(tree, true);
}

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

/**
 * Maps the 6th component of this tuple to a new value.
 *
 * @param <U> new type of the 6th component
 * @param mapper A mapping function
 * @return a new tuple based on this tuple and substituted 6th component
 */
public <U> Tuple6<T1, T2, T3, T4, T5, U> map6(Function<? super T6, ? extends U> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  final U u = mapper.apply(_6);
  return Tuple.of(_1, _2, _3, _4, _5, u);
}

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

/**
 * Maps the 1st component of this tuple to a new value.
 *
 * @param <U> new type of the 1st component
 * @param mapper A mapping function
 * @return a new tuple based on this tuple and substituted 1st component
 */
public <U> Tuple5<U, T2, T3, T4, T5> map1(Function<? super T1, ? extends U> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  final U u = mapper.apply(_1);
  return Tuple.of(u, _2, _3, _4, _5);
}

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

/**
 * Maps the 3rd component of this tuple to a new value.
 *
 * @param <U> new type of the 3rd component
 * @param mapper A mapping function
 * @return a new tuple based on this tuple and substituted 3rd component
 */
public <U> Tuple7<T1, T2, U, T4, T5, T6, T7> map3(Function<? super T3, ? extends U> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  final U u = mapper.apply(_3);
  return Tuple.of(_1, _2, u, _4, _5, _6, _7);
}

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

/**
 * Maps the 4th component of this tuple to a new value.
 *
 * @param <U> new type of the 4th component
 * @param mapper A mapping function
 * @return a new tuple based on this tuple and substituted 4th component
 */
public <U> Tuple7<T1, T2, T3, U, T5, T6, T7> map4(Function<? super T4, ? extends U> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  final U u = mapper.apply(_4);
  return Tuple.of(_1, _2, _3, u, _5, _6, _7);
}

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

/**
 * Maps the 5th component of this tuple to a new value.
 *
 * @param <U> new type of the 5th component
 * @param mapper A mapping function
 * @return a new tuple based on this tuple and substituted 5th component
 */
public <U> Tuple7<T1, T2, T3, T4, U, T6, T7> map5(Function<? super T5, ? extends U> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  final U u = mapper.apply(_5);
  return Tuple.of(_1, _2, _3, _4, u, _6, _7);
}

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

@Override
public <V2> Multimap<K, V2> mapValues(Function<? super V, ? extends V2> valueMapper) {
  Objects.requireNonNull(valueMapper, "valueMapper is null");
  return map((k, v) -> Tuple.of(k, valueMapper.apply(v)));
}

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

@Override
public Tuple2<CharSeq, CharSeq> splitAt(int n) {
  if (n <= 0) {
    return Tuple.of(EMPTY, this);
  } else if (n >= length()) {
    return Tuple.of(this, EMPTY);
  } else {
    return Tuple.of(of(back.substring(0, n)), of(back.substring(n)));
  }
}

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

@Override
public <V2> HashMap<K, V2> mapValues(Function<? super V, ? extends V2> valueMapper) {
  Objects.requireNonNull(valueMapper, "valueMapper is null");
  return map((k, v) -> Tuple.of(k, valueMapper.apply(v)));
}

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

@Override
public Tuple2<Array<T>, Array<T>> splitAt(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final Array<T> init = takeWhile(predicate.negate());
  return Tuple.of(init, drop(init.length()));
}

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

@Override
default <T1, T2> Tuple2<Stream<T1>, Stream<T2>> unzip(
    Function<? super T, Tuple2<? extends T1, ? extends T2>> unzipper) {
  Objects.requireNonNull(unzipper, "unzipper is null");
  final Stream<Tuple2<? extends T1, ? extends T2>> stream = map(unzipper);
  final Stream<T1> stream1 = stream.map(t -> t._1);
  final Stream<T2> stream2 = stream.map(t -> t._2);
  return Tuple.of(stream1, stream2);
}

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

@SuppressWarnings("unchecked")
@Override
public Tuple2<M, M> partition(Predicate<? super Tuple2<K, V>> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final Tuple2<Iterator<Tuple2<K, V>>, Iterator<Tuple2<K, V>>> p = iterator().partition(predicate);
  return Tuple.of((M) createFromEntries(p._1), (M) createFromEntries(p._2));
}

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

@Override
default <T1, T2, T3> Tuple3<Stream<T1>, Stream<T2>, Stream<T3>> unzip3(
    Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) {
  Objects.requireNonNull(unzipper, "unzipper is null");
  final Stream<Tuple3<? extends T1, ? extends T2, ? extends T3>> stream = map(unzipper);
  final Stream<T1> stream1 = stream.map(t -> t._1);
  final Stream<T2> stream2 = stream.map(t -> t._2);
  final Stream<T3> stream3 = stream.map(t -> t._3);
  return Tuple.of(stream1, stream2, stream3);
}

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

@Override
public Iterator<Tuple2<K, V>> iterator() {
  if (containerType == ContainerType.SORTED_SET) {
    return back.iterator().flatMap(t -> t._2.iterator().map(v -> Tuple.of(t._1, v)));
  } else {
    return back.iterator().flatMap(t -> t._2.map(v -> Tuple.of(t._1, v)));
  }
}

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

@Override
default Tuple2<Stream<T>, Stream<T>> splitAtInclusive(Predicate<? super T> predicate) {
  final Tuple2<Stream<T>, Stream<T>> split = splitAt(predicate);
  if (split._2.isEmpty()) {
    return split;
  } else {
    return Tuple.of(split._1.append(split._2.head()), split._2.tail());
  }
}

相关文章

微信公众号

最新文章

更多

Tuple类方法