本文整理了Java中io.vavr.collection.Vector.append()
方法的一些代码示例,展示了Vector.append()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.append()
方法的具体详情如下:
包路径:io.vavr.collection.Vector
类名称:Vector
方法名:append
暂无
代码示例来源:origin: vavr-io/vavr
@Override
public <T1, T2, T3> Tuple3<Vector<T1>, Vector<T2>, Vector<T3>> unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) {
Objects.requireNonNull(unzipper, "unzipper is null");
Vector<T1> xs = empty();
Vector<T2> ys = empty();
Vector<T3> zs = empty();
for (int i = 0; i < length(); i++) {
final Tuple3<? extends T1, ? extends T2, ? extends T3> t = unzipper.apply(get(i));
xs = xs.append(t._1);
ys = ys.append(t._2);
zs = zs.append(t._3);
}
return Tuple.of(xs, ys, zs);
}
代码示例来源:origin: vavr-io/vavr
@Override
public Vector<Vector<T>> permutations() {
if (isEmpty()) {
return empty();
} else if (length() == 1) {
return of(this);
} else {
Vector<Vector<T>> results = empty();
for (T t : distinct()) {
for (Vector<T> ts : remove(t).permutations()) {
results = results.append(of(t).appendAll(ts));
}
}
return results;
}
}
代码示例来源:origin: vavr-io/vavr
@Override
public <T1, T2> Tuple2<Vector<T1>, Vector<T2>> unzip(Function<? super T, Tuple2<? extends T1, ? extends T2>> unzipper) {
Objects.requireNonNull(unzipper, "unzipper is null");
Vector<T1> xs = empty();
Vector<T2> ys = empty();
for (int i = 0; i < length(); i++) {
final Tuple2<? extends T1, ? extends T2> t = unzipper.apply(get(i));
xs = xs.append(t._1);
ys = ys.append(t._2);
}
return Tuple.of(xs, ys);
}
代码示例来源:origin: io.vavr/vavr
@Override
public Vector<Vector<T>> permutations() {
if (isEmpty()) {
return empty();
} else if (length() == 1) {
return of(this);
} else {
Vector<Vector<T>> results = empty();
for (T t : distinct()) {
for (Vector<T> ts : remove(t).permutations()) {
results = results.append(of(t).appendAll(ts));
}
}
return results;
}
}
代码示例来源:origin: vavr-io/vavr
/**
* Reduces many {@code Option}s into a single {@code Option} by transforming an
* {@code Iterable<Option<? extends T>>} into a {@code Option<Seq<T>>}. If any of
* the Options are {@link Option.None}, then this returns {@link Option.None}.
*
* @param values An {@code Iterable} of {@code Option}s
* @param <T> type of the Options
* @return An {@code Option} of a {@link Seq} of results
* @throws NullPointerException if {@code values} is null
*/
static <T> Option<Seq<T>> sequence(Iterable<? extends Option<? extends T>> values) {
Objects.requireNonNull(values, "values is null");
Vector<T> vector = Vector.empty();
for (Option<? extends T> value : values) {
if (value.isEmpty()) {
return Option.none();
}
vector = vector.append(value.get());
}
return Option.some(vector);
}
代码示例来源:origin: vavr-io/vavr
/**
* Reduces many {@code Try}s into a single {@code Try} by transforming an
* {@code Iterable<Try<? extends T>>} into a {@code Try<Seq<T>>}. If any of
* the {@code Try}s are {@link Try.Failure}, then this returns a {@link Try.Failure}.
*
* @param values An {@link Iterable} of {@code Try}s
* @param <T> type of the Trys
* @return A {@code Try} of a {@link Seq} of results
* @throws NullPointerException if {@code values} is null
*/
static <T> Try<Seq<T>> sequence(Iterable<? extends Try<? extends T>> values) {
Objects.requireNonNull(values, "values is null");
Vector<T> vector = Vector.empty();
for (Try<? extends T> value : values) {
if (value.isFailure()) {
return Try.failure(value.getCause());
}
vector = vector.append(value.get());
}
return Try.success(vector);
}
代码示例来源:origin: vavr-io/vavr
for (Either<? extends L, ? extends R> either : eithers) {
if (either.isRight()) {
rightValues = rightValues.append(either.get());
} else {
return Either.left(either.getLeft());
代码示例来源:origin: martincooper/java-datatable
/**
* Adds - Appends a new item to the end of the vector.
*
* @param vector The vector to add the item to.
* @param item The item to add.
* @param <T> The vector type.
* @return Returns the new vector with the item added.
*/
public static <T> Try<Vector<T>> addItem(Vector<T> vector, T item) {
return Try.success(vector.append(item));
}
代码示例来源:origin: io.vavr/vavr
@Override
public <T1, T2, T3> Tuple3<Vector<T1>, Vector<T2>, Vector<T3>> unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) {
Objects.requireNonNull(unzipper, "unzipper is null");
Vector<T1> xs = empty();
Vector<T2> ys = empty();
Vector<T3> zs = empty();
for (int i = 0; i < length(); i++) {
final Tuple3<? extends T1, ? extends T2, ? extends T3> t = unzipper.apply(get(i));
xs = xs.append(t._1);
ys = ys.append(t._2);
zs = zs.append(t._3);
}
return Tuple.of(xs, ys, zs);
}
代码示例来源:origin: io.vavr/vavr
@Override
public <T1, T2> Tuple2<Vector<T1>, Vector<T2>> unzip(Function<? super T, Tuple2<? extends T1, ? extends T2>> unzipper) {
Objects.requireNonNull(unzipper, "unzipper is null");
Vector<T1> xs = empty();
Vector<T2> ys = empty();
for (int i = 0; i < length(); i++) {
final Tuple2<? extends T1, ? extends T2> t = unzipper.apply(get(i));
xs = xs.append(t._1);
ys = ys.append(t._2);
}
return Tuple.of(xs, ys);
}
代码示例来源:origin: martincooper/java-datatable
/**
* Adds / Appends and item to the end of the column.
*
* @param value The value to append.
* @return Returns a new DataColumn with the new item appended.
*/
public Try<DataColumn<T>> addItem(T value) {
return Try.success(createColumn(this.data.append(value)));
}
代码示例来源:origin: io.vavr/vavr
/**
* Reduces many {@code Option}s into a single {@code Option} by transforming an
* {@code Iterable<Option<? extends T>>} into a {@code Option<Seq<T>>}. If any of
* the Options are {@link Option.None}, then this returns {@link Option.None}.
*
* @param values An {@code Iterable} of {@code Option}s
* @param <T> type of the Options
* @return An {@code Option} of a {@link Seq} of results
* @throws NullPointerException if {@code values} is null
*/
static <T> Option<Seq<T>> sequence(Iterable<? extends Option<? extends T>> values) {
Objects.requireNonNull(values, "values is null");
Vector<T> vector = Vector.empty();
for (Option<? extends T> value : values) {
if (value.isEmpty()) {
return Option.none();
}
vector = vector.append(value.get());
}
return Option.some(vector);
}
代码示例来源:origin: io.vavr/vavr
/**
* Reduces many {@code Try}s into a single {@code Try} by transforming an
* {@code Iterable<Try<? extends T>>} into a {@code Try<Seq<T>>}. If any of
* the {@code Try}s are {@link Try.Failure}, then this returns a {@link Try.Failure}.
*
* @param values An {@link Iterable} of {@code Try}s
* @param <T> type of the Trys
* @return A {@code Try} of a {@link Seq} of results
* @throws NullPointerException if {@code values} is null
*/
static <T> Try<Seq<T>> sequence(Iterable<? extends Try<? extends T>> values) {
Objects.requireNonNull(values, "values is null");
Vector<T> vector = Vector.empty();
for (Try<? extends T> value : values) {
if (value.isFailure()) {
return Try.failure(value.getCause());
}
vector = vector.append(value.get());
}
return Try.success(vector);
}
代码示例来源:origin: io.vavr/vavr
for (Either<? extends L, ? extends R> either : eithers) {
if (either.isRight()) {
rightValues = rightValues.append(either.get());
} else {
return Either.left(either.getLeft());
代码示例来源:origin: martincooper/java-datatable
/**
* Attempts to add / append a new item to the end of the column.
* A type check is performed before addition.
*
* @param value The item required to be added.
* @return Returns a Success with the new modified DataColumn, or a Failure.
*/
@Override
public Try<IDataColumn> add(Object value) {
return Match(GenericExtensions.tryCast(this.type, value)).of(
Case($Success($()), typedVal -> Try.of(() -> createColumn(this.data.append(typedVal)))),
Case($Failure($()), DataTableException.tryError("tryAdd failed. Item of invalid type passed."))
);
}
内容来源于网络,如有侵权,请联系作者删除!