@Override default boolean startsWith(Iterable<? extends T> that, int offset) { Objects.requireNonNull(that, "that is null"); if (offset < 0) return false; if (that instanceof IndexedSeq) { IndexedSeq<? extends T> dhat = (IndexedSeq<? extends T>) that; int i = offset; int j = 0; int thisLen = length(); int thatLen = dhat.length(); while (i < thisLen && j < thatLen && Objects.equals(this.get(i), dhat.get(j))) { i++; j++; } return j == thatLen; } else { int i = offset; int thisLen = length(); java.util.Iterator<? extends T> thatElems = that.iterator(); while (i < thisLen && thatElems.hasNext()) { if (!Objects.equals(this.get(i), thatElems.next())) { return false; } i++; } return !thatElems.hasNext(); } }
private static <T> int findSlice(IndexedSeq<T> t, int p, int maxPtr, IndexedSeq<T> slice) { while (p <= maxPtr) { if (t.startsWith(slice, p)) { return p; } p++; } return -1; }
static <T> int lastIndexOfSlice(IndexedSeq<T> t, IndexedSeq<T> slice, int end) { if (end < 0) { return -1; } if (t.isEmpty()) { return slice.isEmpty() ? 0 : -1; } if (slice.isEmpty()) { int len = t.length(); return len < end ? len : end; } int p = 0; int result = -1; final int maxPtr = t.length() - slice.length(); while (p <= maxPtr) { int r = findSlice(t, p, maxPtr, slice); if (r < 0) { return result; } if (r <= end) { result = r; p = r + 1; } else { return result; } } return result; }
public final V getValueAt(int index) { return values.get(index); }
public final Stream<V> valueStream() { return values.toStream(); }
@Override public final int getRowCount() { return values.length(); }