@Test public void limit() { assertSame(seq, seq.limit(2)); ReverseSequence limited = seq.limit(1); assertEquals(6, limited.getBegin()); assertEquals(7, limited.getEnd()); assertEquals(1, limited.size()); assertArrayEquals(new int[]{6}, limited.stream().toArray()); }
@Override public ReverseSequence limit(int n) { if (n < 0 || n > size()) throw new NoSuchElementException("index " + n + " outside range [0.." + size() + "]"); if (n == size()) return this; return new ReverseSequence(end - n, end); }
ReverseSequence implements Sequence { @Override public ReverseSequence limit(int n) { if (n < 0 || n > size()) throw new NoSuchElementException("index " + n + " outside range [0.." + size() + "]"); if (n == size()) return this; return new ReverseSequence(end - n, end); } }
ReverseSequence implements Sequence { @Override public ReverseSequence limit(int n) { if (n < 0 || n > size()) throw new NoSuchElementException("index " + n + " outside range [0.." + size() + "]"); if (n == size()) return this; return new ReverseSequence(end - n, end); }  }
ReverseSequence implements Sequence { @Override public ReverseSequence limit(int n) { if (n < 0 || n > size()) throw new NoSuchElementException("index " + n + " outside range [0.." + size() + "]"); if (n == size()) return this; return new ReverseSequence(end - n, end); }  @Override Comparator<C> getComparator(); @Override int get(int n); @Override ReverseSequence limit(int n); @Override ReverseSequence skip(int n); @Override Spliterator.OfInt spliterator(); @Override Iterator<Integer> iterator(); @Override IntStream stream(); @Override IntStream parallelStream(); @Override Sequence reverse(); @Override int size(); }
ReverseSequence implements Sequence { @Override public ReverseSequence limit(int n) { if (n < 0 || n > size()) throw new NoSuchElementException("index " + n + " outside range [0.." + size() + "]"); if (n == size()) return this; return new ReverseSequence(end - n, end); }  @Override Comparator<C> getComparator(); @Override int get(int n); @Override ReverseSequence limit(int n); @Override ReverseSequence skip(int n); @Override Spliterator.OfInt spliterator(); @Override Iterator<Integer> iterator(); @Override IntStream stream(); @Override IntStream parallelStream(); @Override Sequence reverse(); @Override int size(); static int SPLITERATOR_CHARACTERISTICS; }