コード例 #1
0
  private List<Integer> getNeighbourhood(final E e) {
    int currentIteration = getIteration();
    if (currentIteration > lastIteration || nHoods == null || perCall) {
      lastIteration = currentIteration;
      nHoods =
          getNeighbourhoods(distanceMeasure, radius, neighbourhoodSize)
              .f(
                  P.p(
                      List.<Entity>iterableList((java.util.List<Entity>) entities).zipIndex(),
                      List.<List<Integer>>nil()));
    }

    final int index = entities.indexOf(e);
    return nHoods
        .find(
            new F<List<Integer>, Boolean>() {
              @Override
              public Boolean f(List<Integer> a) {
                return a.exists(Equal.intEqual.eq(index));
              }
            })
        .orSome(List.single(index));
  }
コード例 #2
0
ファイル: V2.java プロジェクト: supermarkion/codeBackup
 /**
  * Returns a nonempty list with the elements of this vector.
  *
  * @return a nonempty list with the elements of this vector.
  */
 public NonEmptyList<A> toNonEmptyList() {
   return NonEmptyList.nel(_1(), List.single(_2()));
 }