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

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

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

Vector.get介绍

暂无

代码示例

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

@Override
public int lastIndexOf(T element, int end) {
  for (int i = Math.min(end, length() - 1); i >= 0; i--) {
    if (Objects.equals(get(i), element)) {
      return i;
    }
  }
  return -1;
}

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

@Override
public int indexOf(T element, int from) {
  for (int i = from; i < length(); i++) {
    if (Objects.equals(get(i), element)) {
      return i;
    }
  }
  return -1;
}

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

@Override
public T head() {
  if (nonEmpty()) {
    return get(0);
  } else {
    throw new NoSuchElementException("head of empty Vector");
  }
}

代码示例来源: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> removeFirst(Predicate<T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  for (int i = 0; i < length(); i++) {
    if (predicate.test(get(i))) {
      return removeAt(i);
    }
  }
  return this;
}

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

@Override
public Vector<T> removeLast(Predicate<T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  for (int i = length() - 1; i >= 0; i--) {
    if (predicate.test(get(i))) {
      return removeAt(i);
    }
  }
  return this;
}

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

@Override
public Vector<T> remove(T element) {
  for (int i = 0; i < length(); i++) {
    if (Objects.equals(get(i), element)) {
      return removeAt(i);
    }
  }
  return this;
}

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

@Override
public Tuple2<Vector<T>, Vector<T>> partition(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final ArrayList<T> left = new ArrayList<>(), right = new ArrayList<>();
  for (int i = 0; i < length(); i++) {
    final T t = get(i);
    (predicate.test(t) ? left : right).add(t);
  }
  return Tuple.of(ofAll(left), ofAll(right));
}

代码示例来源: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: 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 Tuple2<Vector<T>, Vector<T>> splitAtInclusive(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  for (int i = 0; i < length(); i++) {
    final T value = get(i);
    if (predicate.test(value)) {
      return (i == (length() - 1)) ? Tuple.of(this, empty())
                     : Tuple.of(take(i + 1), drop(i + 1));
    }
  }
  return Tuple.of(this, empty());
}

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

/**
 * Returns the Data Row at the specified index.
 *
 * @param rowIndex The row index.
 * @return Returns the Data Row.
 */
public DataRow get(Integer rowIndex) {
  return this.rows.get(rowIndex);
}

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

@Override
public T head() {
  if (nonEmpty()) {
    return get(0);
  } else {
    throw new NoSuchElementException("head of empty Vector");
  }
}

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

@Override
public int lastIndexOf(T element, int end) {
  for (int i = Math.min(end, length() - 1); i >= 0; i--) {
    if (Objects.equals(get(i), element)) {
      return i;
    }
  }
  return -1;
}

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

@Override
public int indexOf(T element, int from) {
  for (int i = from; i < length(); i++) {
    if (Objects.equals(get(i), element)) {
      return i;
    }
  }
  return -1;
}

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

/**
 * Returns the IDataColumn by name.
 *
 * @param columnName The name of the IDataColumn.
 * @return Returns the IDataColumn.
 */
public IDataColumn get(String columnName) {
  return this.columns.get(columnIdxByName(columnName));
}

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

@Override
public Vector<T> removeLast(Predicate<T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  for (int i = length() - 1; i >= 0; i--) {
    if (predicate.test(get(i))) {
      return removeAt(i);
    }
  }
  return this;
}

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

@Override
public Vector<T> remove(T element) {
  for (int i = 0; i < length(); i++) {
    if (Objects.equals(get(i), element)) {
      return removeAt(i);
    }
  }
  return this;
}

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

@Override
public Tuple2<Vector<T>, Vector<T>> splitAtInclusive(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  for (int i = 0; i < length(); i++) {
    final T value = get(i);
    if (predicate.test(value)) {
      return (i == (length() - 1)) ? Tuple.of(this, empty())
                     : Tuple.of(take(i + 1), drop(i + 1));
    }
  }
  return Tuple.of(this, empty());
}

相关文章