io.vavr.collection.Vector.iterator()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(193)

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

Vector.iterator介绍

暂无

代码示例

代码示例来源: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 <U, R> Vector<R> zipWith(Iterable<? extends U> that, BiFunction<? super T, ? super U, ? extends R> mapper) {
  Objects.requireNonNull(that, "that is null");
  Objects.requireNonNull(mapper, "mapper is null");
  return ofAll(iterator().zipWith(that, mapper));
}

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

@Override
public <U> Vector<U> zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  return ofAll(iterator().zipWithIndex(mapper));
}

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

@Override
public <U> Vector<U> flatMap(Function<? super T, ? extends Iterable<? extends U>> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  final Iterator<? extends U> results = iterator().flatMap(mapper);
  return ofAll(results);
}

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

@Override
public <U> Vector<Tuple2<T, U>> zipAll(Iterable<? extends U> that, T thisElem, U thatElem) {
  Objects.requireNonNull(that, "that is null");
  return ofAll(iterator().zipAll(that, thisElem, thatElem));
}

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

@Override
public <R> Vector<R> collect(PartialFunction<? super T, ? extends R> partialFunction) {
  return ofAll(iterator().<R> collect(partialFunction));
}

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

@Override
public Iterator<Vector<T>> slideBy(Function<? super T, ?> classifier) {
  return iterator().slideBy(classifier).map(Vector::ofAll);
}

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

@Override
public Iterator<Vector<T>> sliding(int size, int step) {
  return iterator().sliding(size, step).map(Vector::ofAll);
}

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

@Override
public Vector<T> intersperse(T element) { return ofAll(iterator().intersperse(element)); }

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

/**
 * Chooses one of the given generators according to their frequency.
 * Only generators with positive frequencies ares used in returned
 * generator.
 *
 * @param generators A non-empty traversable of Tuples (frequency, generator)
 * @param <T>        Type to be generated
 * @return A new T generator
 * @throws java.lang.NullPointerException     if generators is null
 * @throws java.lang.IllegalArgumentException if generators doesn't contain any generator with positive frequency
 */
static <T> Gen<T> frequency(Iterable<Tuple2<Integer, Gen<T>>> generators) {
  Objects.requireNonNull(generators, "generators is null");
  final Vector<Tuple2<Integer, Gen<T>>> filtered = Iterator.ofAll(generators)
      .filter(t -> t._1() > 0).toVector();
  if (filtered.isEmpty()) {
    throw new IllegalArgumentException("no generator with positive weight");
  }
  final int size = filtered.map(t -> t._1).sum().intValue();
  return choose(1, size).flatMap(n -> GenModule.frequency(n, filtered.iterator()));
}

代码示例来源:origin: martincooper/java-datatable

/**
 * Returns an iterator over elements of type IDataColumn.
 *
 * @return an Iterator.
 */
@Override
public Iterator<IDataColumn> iterator() {
  return this.columns.iterator();
}

代码示例来源:origin: martincooper/java-datatable

/**
 * Returns an iterator over elements of DataRow.
 *
 * @return an Iterator.
 */
@Override
public Iterator<DataRow> iterator() {
  return rows.iterator();
}

代码示例来源: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: io.vavr/vavr

@Override
public <U, R> Vector<R> zipWith(Iterable<? extends U> that, BiFunction<? super T, ? super U, ? extends R> mapper) {
  Objects.requireNonNull(that, "that is null");
  Objects.requireNonNull(mapper, "mapper is null");
  return ofAll(iterator().zipWith(that, mapper));
}

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

@Override
public <U> Vector<U> zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  return ofAll(iterator().zipWithIndex(mapper));
}

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

@Override
public <U> Vector<U> flatMap(Function<? super T, ? extends Iterable<? extends U>> mapper) {
  Objects.requireNonNull(mapper, "mapper is null");
  final Iterator<? extends U> results = iterator().flatMap(mapper);
  return ofAll(results);
}

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

@Override
public <U> Vector<Tuple2<T, U>> zipAll(Iterable<? extends U> that, T thisElem, U thatElem) {
  Objects.requireNonNull(that, "that is null");
  return ofAll(iterator().zipAll(that, thisElem, thatElem));
}

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

@Override
public Iterator<Vector<T>> slideBy(Function<? super T, ?> classifier) {
  return iterator().slideBy(classifier).map(Vector::ofAll);
}

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

@Override
public <R> Vector<R> collect(PartialFunction<? super T, ? extends R> partialFunction) {
  return ofAll(iterator().<R> collect(partialFunction));
}

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

@Override
public Iterator<Vector<T>> sliding(int size, int step) {
  return iterator().sliding(size, step).map(Vector::ofAll);
}

相关文章