Package org.ametys.plugins.repository
Class CollatingUniqueAmetysObjectIterable.CollatingIterator
- java.lang.Object
-
- org.ametys.plugins.repository.CollatingUniqueAmetysObjectIterable.CollatingIterator
-
- All Implemented Interfaces:
Iterator<A>,AmetysObjectIterator<A>
- Enclosing class:
- CollatingUniqueAmetysObjectIterable<A extends AmetysObject>
class CollatingUniqueAmetysObjectIterable.CollatingIterator extends Object implements AmetysObjectIterator<A>
-
-
Field Summary
Fields Modifier and Type Field Description private Set<String>_identifiersThe already resolved identifiers.private int_itCountThe iterable count.private List<AmetysObjectIterator<A>>_itsprivate ArrayList<A>_nextObjectsNextobjects peeked from each iterator.private BitSet_nextObjectSetWhether or not each object has been prefetched.private long_positionThe current position in the iterator.private long_size
-
Constructor Summary
Constructors Constructor Description CollatingIterator(List<AmetysObjectIterator<A>> its, long size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_clear(int iterableIndex)Clears the_nextObjectsand_nextObjectSetattributes at position i.private void_initialize()Initializes the collating state if it hasn't been already.private int_least()Returns the index of the least element in_nextObjects,settingany uninitialized values.private boolean_setNextObject(int iterableIndex)Sets the_nextObjectsand_nextObjectSetattributes at position i to the next value of theiteratorat position i, or clear them if the ith iterator has no next value.longgetPosition()Returns the current position within the iterator.longgetSize()Returns the number of elements in the iterator.booleanhasNext()Anext()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.repository.AmetysObjectIterator
skip
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
_position
private long _position
The current position in the iterator.
-
_nextObjects
private ArrayList<A extends AmetysObject> _nextObjects
Nextobjects peeked from each iterator.
-
_nextObjectSet
private BitSet _nextObjectSet
Whether or not each object has been prefetched.
-
_identifiers
private Set<String> _identifiers
The already resolved identifiers.
-
_itCount
private int _itCount
The iterable count.
-
_its
private List<AmetysObjectIterator<A extends AmetysObject>> _its
-
_size
private long _size
-
-
Constructor Detail
-
CollatingIterator
public CollatingIterator(List<AmetysObjectIterator<A>> its, long size)
-
-
Method Detail
-
getPosition
public long getPosition()
Description copied from interface:AmetysObjectIteratorReturns the current position within the iterator. The number returned is the 0-based index of the next element in the iterator, i.e. the one that will be returned on the subsequentnextcall.
Note that this method does not check if there is a next element, i.e. an empty iterator will always return 0.- Specified by:
getPositionin interfaceAmetysObjectIterator<A extends AmetysObject>- Returns:
- a long
-
getSize
public long getSize()
Description copied from interface:AmetysObjectIteratorReturns the number of elements in the iterator. If this information is unavailable, returns -1.- Specified by:
getSizein interfaceAmetysObjectIterator<A extends AmetysObject>- Returns:
- a long
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfaceIterator<A extends AmetysObject>
-
next
public A next() throws NoSuchElementException
- Specified by:
nextin interfaceIterator<A extends AmetysObject>- Throws:
NoSuchElementException
-
_initialize
private void _initialize()
Initializes the collating state if it hasn't been already.
-
_setNextObject
private boolean _setNextObject(int iterableIndex)
Sets the_nextObjectsand_nextObjectSetattributes at position i to the next value of theiteratorat position i, or clear them if the ith iterator has no next value.- Parameters:
iterableIndex- The index to get in _iterables- Returns:
falseif there was no value to set
-
_clear
private void _clear(int iterableIndex)
Clears the_nextObjectsand_nextObjectSetattributes at position i.- Parameters:
iterableIndex- The index to clear in _iterables
-
_least
private int _least()
Returns the index of the least element in_nextObjects,settingany uninitialized values.- Returns:
- the index of the least element
- Throws:
IllegalStateException- if an error occurred
-
-