本文整理了Java中io.vavr.collection.Vector.update()
方法的一些代码示例,展示了Vector.update()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.update()
方法的具体详情如下:
包路径:io.vavr.collection.Vector
类名称:Vector
方法名:update
暂无
代码示例来源:origin: vavr-io/vavr
@Override
public Vector<T> replaceAll(T currentElement, T newElement) {
Vector<T> result = this;
int index = 0;
for (T value : iterator()) {
if (Objects.equals(value, currentElement)) {
result = result.update(index, newElement);
}
index++;
}
return result;
}
代码示例来源:origin: vavr-io/vavr
@Override
public Vector<T> update(int index, Function<? super T, ? extends T> updater) {
Objects.requireNonNull(updater, "updater is null");
return update(index, updater.apply(get(index)));
}
代码示例来源:origin: vavr-io/vavr
@Override
public Vector<T> replace(T currentElement, T newElement) {
return indexOfOption(currentElement)
.map(i -> update(i, newElement))
.getOrElse(this);
}
代码示例来源:origin: io.vavr/vavr
@Override
public Vector<T> update(int index, Function<? super T, ? extends T> updater) {
Objects.requireNonNull(updater, "updater is null");
return update(index, updater.apply(get(index)));
}
代码示例来源:origin: io.vavr/vavr
@Override
public Vector<T> replaceAll(T currentElement, T newElement) {
Vector<T> result = this;
int index = 0;
for (T value : iterator()) {
if (Objects.equals(value, currentElement)) {
result = result.update(index, newElement);
}
index++;
}
return result;
}
代码示例来源:origin: martincooper/java-datatable
/**
* Replaces the existing item at the specified index with the new item.
*
* @param index The index to replace the existing item.
* @param value The new item to replace the existing one.
* @return Returns a new DataColumn with the specified item replaced.
*/
public Try<DataColumn<T>> replaceItem(Integer index, T value) {
return Try.of(() -> createColumn(this.data.update(index, value)));
}
代码示例来源:origin: io.vavr/vavr
@Override
public Vector<T> replace(T currentElement, T newElement) {
return indexOfOption(currentElement)
.map(i -> update(i, newElement))
.getOrElse(this);
}
代码示例来源:origin: martincooper/java-datatable
/**
* Replaces - Updates an item in the vector, with additional bounds check.
*
* @param vector The vector to replace the item in.
* @param index The index of the item to replace.
* @param item The new item.
* @param <T> The vector type.
* @return Returns the new vector with the item replaced.
*/
public static <T> Try<Vector<T>> replaceItem(Vector<T> vector, Integer index, T item) {
return outOfBounds(vector, index)
? error("Item index out of bounds for replace.")
: Try.success(vector.update(index, item));
}
代码示例来源:origin: martincooper/java-datatable
/**
* Attempts to replace an existing item with a new item in the column.
* A type check is performed before replacement.
*
* @param index The index the item is to be replaced at.
* @param value The new item.
* @return Returns a Success with the new modified DataColumn, or a Failure.
*/
@Override
public Try<IDataColumn> replace(Integer index, Object value) {
return Match(GenericExtensions.tryCast(this.type, value)).of(
Case($Success($()), typedVal -> Try.of(() -> createColumn(this.data.update(index, typedVal)))),
Case($Failure($()), DataTableException.tryError("tryReplace failed. Item of invalid type passed."))
);
}
内容来源于网络,如有侵权,请联系作者删除!