@Test public void testAscendingIterator() { SortedIntArray s1 = new SortedIntArray(1,3,4); PrimitiveIterator.OfInt it = s1.getAscendingIterator(0); assertItEquals(it, 1, 3, 4); it = s1.getAscendingIterator(1); assertItEquals(it, 1, 3, 4); it = s1.getAscendingIterator(2); assertItEquals(it, 3, 4); it = s1.getAscendingIterator(4); assertItEquals(it, 4); it = s1.getAscendingIterator(5); assertFalse(it.hasNext()); }
public PrimitiveIterator.OfInt getAscendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } } @Override public boolean hasNext() { return pos < length; } @Override public int nextInt() { return a[pos++]; } }; }
SortedIntArray implements Serializable { public PrimitiveIterator.OfInt getAscendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } } @Override public boolean hasNext() { return pos < length; } @Override public int nextInt() { return a[pos++]; } }; } }
SortedIntArray implements Serializable { public PrimitiveIterator.OfInt getAscendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } } @Override public boolean hasNext() { return pos < length; } @Override public int nextInt() { return a[pos++]; } }; } SortedIntArray();  SortedIntArray(int capacity);  SortedIntArray(int... array); }
SortedIntArray implements Serializable { public PrimitiveIterator.OfInt getAscendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } } @Override public boolean hasNext() { return pos < length; } @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 getAscendingIterator(int startFrom) { return new PrimitiveIterator.OfInt() { int pos; { pos = search(startFrom); if (pos < 0) { pos = -pos - 1; } } @Override public boolean hasNext() { return pos < length; } @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; }