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>
_identifiers
The already resolved identifiers.private int
_itCount
The iterable count.private List<AmetysObjectIterator<A>>
_its
private ArrayList<A>
_nextObjects
Next
objects peeked from each iterator.private BitSet
_nextObjectSet
Whether or not each object has been prefetched.private long
_position
The 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_nextObjects
and_nextObjectSet
attributes 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
,setting
any uninitialized values.private boolean
_setNextObject(int iterableIndex)
Sets the_nextObjects
and_nextObjectSet
attributes at position i to the next value of theiterator
at position i, or clear them if the ith iterator has no next value.long
getPosition()
Returns the current position within the iterator.long
getSize()
Returns the number of elements in the iterator.boolean
hasNext()
A
next()
-
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
Next
objects 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:AmetysObjectIterator
Returns 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 subsequentnext
call.
Note that this method does not check if there is a next element, i.e. an empty iterator will always return 0.- Specified by:
getPosition
in interfaceAmetysObjectIterator<A extends AmetysObject>
- Returns:
- a long
-
getSize
public long getSize()
Description copied from interface:AmetysObjectIterator
Returns the number of elements in the iterator. If this information is unavailable, returns -1.- Specified by:
getSize
in interfaceAmetysObjectIterator<A extends AmetysObject>
- Returns:
- a long
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceIterator<A extends AmetysObject>
-
next
public A next() throws NoSuchElementException
- Specified by:
next
in 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_nextObjects
and_nextObjectSet
attributes at position i to the next value of theiterator
at position i, or clear them if the ith iterator has no next value.- Parameters:
iterableIndex
- The index to get in _iterables- Returns:
false
if there was no value to set
-
_clear
private void _clear(int iterableIndex)
Clears the_nextObjects
and_nextObjectSet
attributes at position i.- Parameters:
iterableIndex
- The index to clear in _iterables
-
_least
private int _least()
Returns the index of the least element in_nextObjects
,setting
any uninitialized values.- Returns:
- the index of the least element
- Throws:
IllegalStateException
- if an error occurred
-
-