Beispiel #1
0
  /**
   * Seek first element that match a test
   *
   * @param seekTest Seek test
   * @return First matches element or {@code null} if none match
   */
  public TYPE seekElement(final SeekTest<TYPE> seekTest) {
    for (int index = 0; index < this.size; index++) {
      if (seekTest.isElementSeek(this.array[index]) == true) {
        return this.array[index];
      }
    }

    return null;
  }
Beispiel #2
0
  /**
   * Collect all matches element is a sorted array list of same class element, same comparator, and
   * unique value
   *
   * @param seekTest Test of seek elements
   * @return List of all matches elements
   */
  public SortedArray<TYPE> seekElements(final SeekTest<TYPE> seekTest) {
    @SuppressWarnings("unchecked")
    final SortedArray<TYPE> sortedArray =
        new SortedArray<TYPE>(this.typeClass, this.comparator, this.size, this.unique);

    for (int index = 0; index < this.size; index++) {
      if (seekTest.isElementSeek(this.array[index]) == true) {
        sortedArray.add(this.array[index]);
      }
    }

    return sortedArray;
  }