Klasse WindowIterator<T>
java.lang.Object
de.erichseifert.gral.util.WindowIterator<T>
- Typparameter:
T- Type of the values.
An iterator that turns a sequence of values into a sequence of
overlapping windows. Each call of next() shifts the window by one
value and returns a new list of the current contents.
Iterator<List<Integer>> windows =
new WindowIterator<>(Arrays.asList(1, 2, 3, 4).iterator(), 2);
// yields [1, 2], then [2, 3], then [3, 4]
There is no padding at the ends: m input values and a window of
n produce m − n + 1 windows, and no
window at all if the source is shorter than n. This is what the
window-based filters in de.erichseifert.gral.data.filters are built
on.
Each returned list is a fresh copy, so it may be kept and modified. As
with ConcatenationIterator, remove() is a no-op for
backwards compatibility rather than an exception.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungWindowIterator(Iterator<T> iterator, int windowSize) Initializes a new instance that returns sliding windows of the specified size. -
Methodenübersicht
Von Klasse geerbte Methoden Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitVon Schnittstelle geerbte Methoden Iterator
forEachRemaining
-
Konstruktordetails
-
WindowIterator
Initializes a new instance that returns sliding windows of the specified size. If the source iterator provides fewer values than the window size, no window can be built and the new instance is empty.- Parameter:
iterator- Source iterator.windowSize- Number of values in a window.
-
-
Methodendetails
-
hasNext
-
next
-
remove
-