@Test public void testDescendingIterator() { SortedIntArray s1 = new SortedIntArray(1, 3, 4); PrimitiveIterator.OfInt it = s1.getDescendingIterator(0); assertFalse(it.hasNext()); it = s1.getDescendingIterator(1); assertFalse(it.hasNext()); it = s1.getDescendingIterator(2); assertItEquals(it, 1); it = s1.getDescendingIterator(4); assertItEquals(it, 3, 1); it = s1.getDescendingIterator(5); assertItEquals(it, 4, 3, 1); }
public PrimitiveIterator.OfInt getDescendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } pos--; } @Override public boolean hasNext() { return pos >= 0; } @Override public int nextInt() { return a[pos--]; } }; }
SortedIntArray implements Serializable { public PrimitiveIterator.OfInt getDescendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } pos--; } @Override public boolean hasNext() { return pos >= 0; } @Override public int nextInt() { return a[pos--]; } }; } }
SortedIntArray implements Serializable { public PrimitiveIterator.OfInt getDescendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } pos--; } @Override public boolean hasNext() { return pos >= 0; } @Override public int nextInt() { return a[pos--]; } }; } SortedIntArray();  SortedIntArray(int capacity);  SortedIntArray(int... array); }
SortedIntArray implements Serializable { public PrimitiveIterator.OfInt getDescendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } pos--; } @Override public boolean hasNext() { return pos >= 0; } @Override public int nextInt() { return a[pos--]; } }; } SortedIntArray();  SortedIntArray(int capacity);  SortedIntArray(int... array); int insert(int x); int search(int x); int get(int pos); boolean isEmpty(); int[] getArray(); int size(); PrimitiveIterator.OfInt getAscendingIterator(int startFrom); PrimitiveIterator.OfInt getDescendingIterator(int startFrom); void forEach(IntConsumer action); boolean contains(int x); static SortedIntArray decodeFromVarIntArray(byte[] buf); @Override boolean equals(Object obj); void add(int x); String toString(); @Override int hashCode(); }
SortedIntArray implements Serializable { public PrimitiveIterator.OfInt getDescendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } pos--; } @Override public boolean hasNext() { return pos >= 0; } @Override public int nextInt() { return a[pos--]; } }; } SortedIntArray();  SortedIntArray(int capacity);  SortedIntArray(int... array); int insert(int x); int search(int x); int get(int pos); boolean isEmpty(); int[] getArray(); int size(); PrimitiveIterator.OfInt getAscendingIterator(int startFrom); PrimitiveIterator.OfInt getDescendingIterator(int startFrom); void forEach(IntConsumer action); boolean contains(int x); static SortedIntArray decodeFromVarIntArray(byte[] buf); @Override boolean equals(Object obj); void add(int x); String toString(); @Override int hashCode(); static int DEFAULT_CAPACITY; }