Esempio n. 1
0
 @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();
   }
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 public final V getValueAt(int index) {
   return values.get(index);
 }
Esempio n. 5
0
 public final Stream<V> valueStream() {
   return values.toStream();
 }
Esempio n. 6
0
 @Override
 public final int getRowCount() {
   return values.length();
 }