/** * Gets an iterator over an object array. * * @param <E> the element type * @param array the array over which to iterate * @return an iterator over the array * @throws NullPointerException if array is null */ public static <E> ResettableIterator<E> arrayIterator(final E... array) { return new ObjectArrayIterator<>(array); }
/** * Returns the next element in the array. * * @return the next element in the array * @throws NoSuchElementException if all the elements in the array * have already been returned */ @Override public E next() { if (hasNext() == false) { throw new NoSuchElementException(); } return this.array[this.index++]; }
/** * Resets the iterator back to the start index. */ @Override public void reset() { super.reset(); this.lastItemIndex = -1; }
/** * Gets an iterator over the end part of an object array. * * @param <E> the element type * @param array the array over which to iterate * @param start the index to start iterating at * @return an iterator over part of the array * @throws IndexOutOfBoundsException if start is less than zero or greater * than the length of the array * @throws NullPointerException if array is null */ public static <E> ResettableIterator<E> arrayIterator(final E[] array, final int start) { return new ObjectArrayIterator<>(array, start); }
/** * Gets an iterator over part of an object array. * * @param <E> the element type * @param array the array over which to iterate * @param start the index to start iterating at * @param end the index to finish iterating at * @return an iterator over part of the array * @throws IndexOutOfBoundsException if array bounds are invalid * @throws IllegalArgumentException if end is before start * @throws NullPointerException if array is null */ public static <E> ResettableIterator<E> arrayIterator(final E[] array, final int start, final int end) { return new ObjectArrayIterator<>(array, start, end); }
return new ObjectArrayIterator<>((Object[]) obj);
@Nonnull @Override @SuppressWarnings("unchecked") public Iterator<T> iterator() { return new ObjectArrayIterator<>(elements.values(emptyArray)); }
@Nonnull @Override @SuppressWarnings("unchecked") public Iterator<T> iterator() { T[] arr = elements.values(emptyArray); Arrays.sort(arr, comparator); return new ObjectArrayIterator<>(arr); } }
@Nonnull @Override public Iterator<JDA> iterator() { JDA[] arr = elements.values(EMPTY_ARRAY); return new ObjectArrayIterator<>(arr); }