/** * Returns {@code true} if an element exists at the given index. * The element is not loaded immediately. * * <p><strong>NOTE: This method is for use by iterators only.</strong> * It is not suited for more general usage since it does not check for * negative index and for skipped elements.</p> */ final boolean exists(final int index) { assert index <= numCached : index; return (index < numCached) || canPullMore(); }
/** * Tests if this set has no element. * * @return {@code true} if this set has no element. */ @Override public final boolean isEmpty() { return (numCached == 0) && !canPullMore(); }
/** * Tests if this set has no element. * * @return {@code true} if this set has no element. */ @Override public final boolean isEmpty() { return (numCached == 0) && !canPullMore(); }
/** * Returns {@code true} if an element exists at the given index. * The element is not loaded immediately. * * <p><strong>NOTE: This method is for use by iterators only.</strong> * It is not suited for more general usage since it does not check for * negative index and for skipped elements.</p> */ final boolean exists(final int index) { assert index <= numCached : index; return (index < numCached) || canPullMore(); }
/** * Returns the number of elements in this set. Invoking this method * forces the set to immediately iterates through all remaining elements. * * @return number of elements in the iterator. */ @Override public final int size() { if (canPullMore()) { while (sourceIterator.hasNext()) { cache(next(sourceIterator)); } sourceIterator = null; } return numCached; }
/** * Returns the number of elements in this set. Invoking this method * forces the set to immediately iterates through all remaining elements. * * @return number of elements in the iterator. */ @Override public final int size() { if (canPullMore()) { while (sourceIterator.hasNext()) { cache(next(sourceIterator)); } sourceIterator = null; } return numCached; }
/** * Returns the element at the specified position in this set. * * @param index the index at which to get an element. * @return the element at the requested index. */ final E get(final int index) { assert numCached <= cachedElements.length : numCached; assert index <= numCached : index; if (index >= numCached) { if (canPullMore()) { cache(next(sourceIterator)); } else { throw new NoSuchElementException(); } } return cachedElements[index]; }
/** * Returns the element at the specified position in this set. * * @param index the index at which to get an element. * @return the element at the requested index. */ final E get(final int index) { assert numCached <= cachedElements.length : numCached; assert index <= numCached : index; if (index >= numCached) { if (canPullMore()) { cache(next(sourceIterator)); } else { throw new NoSuchElementException(); } } return cachedElements[index]; }