/** * 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]; }
/** * Caches a new element, possibly substituting the created instance by a previously created instance. * * @param element the element to add to the cache. */ @Override protected void cache(OperationMethod element) { if (element instanceof GeodeticOperation) { final Class<?> variant3D = ((GeodeticOperation) element).variant3D(); if (variant3D != null) { final List<OperationMethod> cached = cached(); for (int i=cached.size(); --i >= 0;) { final OperationMethod m = cached.get(i); if (m.getClass() == variant3D) { for (final GeodeticOperation candidate : ((GeodeticOperation) m).redimensioned) { if (candidate != null && candidate.getClass() == element.getClass()) { element = candidate; break; } } } } } } super.cache(element); } }
/** * Caches a new element, possibly substituting the created instance by a previously created instance. * * @param element the element to add to the cache. */ @Override protected void cache(OperationMethod element) { if (element instanceof GeodeticOperation) { final Class<?> variant3D = ((GeodeticOperation) element).variant3D(); if (variant3D != null) { final List<OperationMethod> cached = cached(); for (int i=cached.size(); --i >= 0;) { final OperationMethod m = cached.get(i); if (m.getClass() == variant3D) { for (final GeodeticOperation candidate : ((GeodeticOperation) m).redimensioned) { if (candidate != null && candidate.getClass() == element.getClass()) { element = candidate; break; } } } } } } super.cache(element); } }