Class FloatIterators
public final class FloatIterators
extends java.lang.Object
- See Also:
Iterator
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFloatIterators.AbstractIndexBasedIteratorA skeletal implementation for an iterator backed by an index-based data store.static classFloatIterators.AbstractIndexBasedListIteratorA skeletal implementation for a list-iterator backed by an index-based data store.static classFloatIterators.EmptyIteratorA class returning no elements and a type-specific iterator interface.static classFloatIterators.UnmodifiableBidirectionalIteratorAn unmodifiable wrapper class for bidirectional iterators.static classFloatIterators.UnmodifiableIteratorAn unmodifiable wrapper class for iterators.static classFloatIterators.UnmodifiableListIteratorAn unmodifiable wrapper class for list iterators. -
Field Summary
Fields Modifier and Type Field Description static FloatIterators.EmptyIteratorEMPTY_ITERATORAn empty iterator. -
Method Summary
Modifier and Type Method Description static booleanall(it.unimi.dsi.fastutil.floats.FloatIterator iterator, FloatPredicate predicate)Returns whether all elements returned by the given iterator satisfy the given predicate.static booleanall(it.unimi.dsi.fastutil.floats.FloatIterator iterator, java.util.function.DoublePredicate predicate)Returns whether all elements returned by the given iterator satisfy the given predicate.static booleanany(it.unimi.dsi.fastutil.floats.FloatIterator iterator, FloatPredicate predicate)Returns whether an element returned by the given iterator satisfies the given predicate.static booleanany(it.unimi.dsi.fastutil.floats.FloatIterator iterator, java.util.function.DoublePredicate predicate)Returns whether an element returned by the given iterator satisfies the given predicate.static it.unimi.dsi.fastutil.floats.FloatIteratorasFloatIterator(java.util.Iterator i)Wraps a standard iterator into a type-specific iterator.static FloatListIteratorasFloatIterator(java.util.ListIterator i)Wraps a standard list iterator into a type-specific list iterator.static it.unimi.dsi.fastutil.floats.FloatIteratorconcat(it.unimi.dsi.fastutil.floats.FloatIterator... a)Concatenates all iterators contained in an array.static it.unimi.dsi.fastutil.floats.FloatIteratorconcat(it.unimi.dsi.fastutil.floats.FloatIterator[] a, int offset, int length)Concatenates a sequence of iterators contained in an array.static intindexOf(it.unimi.dsi.fastutil.floats.FloatIterator iterator, FloatPredicate predicate)Returns the index of the first element returned by the given iterator that satisfies the given predicate, or −1 if no such element was found.static intindexOf(it.unimi.dsi.fastutil.floats.FloatIterator iterator, java.util.function.DoublePredicate predicate)Returns the index of the first element returned by the given iterator that satisfies the given predicate, or −1 if no such element was found.static it.unimi.dsi.fastutil.floats.FloatIteratornarrow(java.util.PrimitiveIterator.OfDouble i)Wrap a JDK primitive iterator to a type-specific iterator, making checked narrowed casts.static FloatListpour(it.unimi.dsi.fastutil.floats.FloatIterator i)Pours an iterator, returning a type-specific list.static FloatListpour(it.unimi.dsi.fastutil.floats.FloatIterator i, int max)Pours an iterator, returning a type-specific list, with a limit on the number of elements.static intpour(it.unimi.dsi.fastutil.floats.FloatIterator i, FloatCollection s)Pours an iterator into a type-specific collection.static intpour(it.unimi.dsi.fastutil.floats.FloatIterator i, FloatCollection s, int max)Pours an iterator into a type-specific collection, with a limit on the number of elements.static FloatListIteratorsingleton(float element)Returns an immutable iterator that iterates just over the given element.static it.unimi.dsi.fastutil.floats.FloatIteratoruncheckedNarrow(java.util.PrimitiveIterator.OfDouble i)Wrap a JDK primitive iterator to a type-specific iterator, making unchecked narrowing casts.static FloatBidirectionalIteratorunmodifiable(FloatBidirectionalIterator i)Returns an unmodifiable bidirectional iterator backed by the specified bidirectional iterator.static it.unimi.dsi.fastutil.floats.FloatIteratorunmodifiable(it.unimi.dsi.fastutil.floats.FloatIterator i)Returns an unmodifiable iterator backed by the specified iterator.static FloatListIteratorunmodifiable(FloatListIterator i)Returns an unmodifiable list iterator backed by the specified list iterator.static float[]unwrap(it.unimi.dsi.fastutil.floats.FloatIterator i)Unwraps an iterator, returning an array.static intunwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, float[] array)Unwraps an iterator into an array.static longunwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, float[][] array)Unwraps an iterator into a big array.static longunwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, float[][] array, long offset, long max)Unwraps an iterator into a big array starting at a given offset for a given number of elements.static intunwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, float[] array, int offset, int max)Unwraps an iterator into an array starting at a given offset for a given number of elements.static float[]unwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, int max)Unwraps an iterator, returning an array, with a limit on the number of elements.static longunwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, FloatCollection c)Unwraps an iterator into a type-specific collection.static intunwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, FloatCollection c, int max)Unwraps an iterator into a type-specific collection, with a limit on the number of elements.static float[][]unwrapBig(it.unimi.dsi.fastutil.floats.FloatIterator i)Unwraps an iterator, returning a big array.static float[][]unwrapBig(it.unimi.dsi.fastutil.floats.FloatIterator i, long max)Unwraps an iterator, returning a big array, with a limit on the number of elements.static it.unimi.dsi.fastutil.doubles.DoubleIteratorwiden(it.unimi.dsi.fastutil.floats.FloatIterator i)Wrap a type-specific iterator to a JDK compatible primitive iterator.static FloatListIteratorwrap(float[] array)Wraps the given array into a type-specific list iterator.static FloatListIteratorwrap(float[] array, int offset, int length)Wraps the given part of an array into a type-specific list iterator.static it.unimi.dsi.fastutil.floats.FloatIteratorwrap(it.unimi.dsi.fastutil.bytes.ByteIterator iterator)Returns an iterator backed by the specified byte iterator.static it.unimi.dsi.fastutil.floats.FloatIteratorwrap(it.unimi.dsi.fastutil.chars.CharIterator iterator)Returns an iterator backed by the specified char iterator.static it.unimi.dsi.fastutil.floats.FloatIteratorwrap(it.unimi.dsi.fastutil.shorts.ShortIterator iterator)Returns an iterator backed by the specified short iterator.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
EMPTY_ITERATOR
An empty iterator. It is serializable and cloneable.The class of this objects represent an abstract empty iterator that can iterate as a type-specific (list) iterator.
-
-
Method Details
-
singleton
Returns an immutable iterator that iterates just over the given element.- Parameters:
element- the only element to be returned by a type-specific list iterator.- Returns:
- an immutable iterator that iterates just over
element.
-
wrap
Wraps the given part of an array into a type-specific list iterator.The type-specific list iterator returned by this method will iterate
lengthtimes, returning consecutive elements of the given array starting from the one with indexoffset.- Parameters:
array- an array to wrap into a type-specific list iterator.offset- the first element of the array to be returned.length- the number of elements to return.- Returns:
- an iterator that will return
lengthelements ofarraystarting at positionoffset.
-
wrap
Wraps the given array into a type-specific list iterator.The type-specific list iterator returned by this method will return all elements of the given array.
- Parameters:
array- an array to wrap into a type-specific list iterator.- Returns:
- an iterator that will return the elements of
array.
-
unwrap
public static int unwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, float[] array, int offset, int max)Unwraps an iterator into an array starting at a given offset for a given number of elements.This method iterates over the given type-specific iterator and stores the elements returned, up to a maximum of
length, in the given array starting atoffset. The number of actually unwrapped elements is returned (it may be less thanmaxif the iterator emits less thanmaxelements).- Parameters:
i- a type-specific iterator.array- an array to contain the output of the iterator.offset- the first element of the array to be returned.max- the maximum number of elements to unwrap.- Returns:
- the number of elements unwrapped.
-
unwrap
public static int unwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, float[] array)Unwraps an iterator into an array.This method iterates over the given type-specific iterator and stores the elements returned in the given array. The iteration will stop when the iterator has no more elements or when the end of the array has been reached.
- Parameters:
i- a type-specific iterator.array- an array to contain the output of the iterator.- Returns:
- the number of elements unwrapped.
-
unwrap
public static float[] unwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, int max)Unwraps an iterator, returning an array, with a limit on the number of elements.This method iterates over the given type-specific iterator and returns an array containing the elements returned by the iterator. At most
maxelements will be returned.- Parameters:
i- a type-specific iterator.max- the maximum number of elements to be unwrapped.- Returns:
- an array containing the elements returned by the iterator (at most
max).
-
unwrap
public static float[] unwrap(it.unimi.dsi.fastutil.floats.FloatIterator i)Unwraps an iterator, returning an array.This method iterates over the given type-specific iterator and returns an array containing the elements returned by the iterator.
- Parameters:
i- a type-specific iterator.- Returns:
- an array containing the elements returned by the iterator.
-
unwrap
public static long unwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, float[][] array, long offset, long max)Unwraps an iterator into a big array starting at a given offset for a given number of elements.This method iterates over the given type-specific iterator and stores the elements returned, up to a maximum of
length, in the given big array starting atoffset. The number of actually unwrapped elements is returned (it may be less thanmaxif the iterator emits less thanmaxelements).- Parameters:
i- a type-specific iterator.array- a big array to contain the output of the iterator.offset- the first element of the array to be returned.max- the maximum number of elements to unwrap.- Returns:
- the number of elements unwrapped.
-
unwrap
public static long unwrap(it.unimi.dsi.fastutil.floats.FloatIterator i, float[][] array)Unwraps an iterator into a big array.This method iterates over the given type-specific iterator and stores the elements returned in the given big array. The iteration will stop when the iterator has no more elements or when the end of the array has been reached.
- Parameters:
i- a type-specific iterator.array- a big array to contain the output of the iterator.- Returns:
- the number of elements unwrapped.
-
unwrap
Unwraps an iterator into a type-specific collection, with a limit on the number of elements.This method iterates over the given type-specific iterator and stores the elements returned, up to a maximum of
max, in the given type-specific collection. The number of actually unwrapped elements is returned (it may be less thanmaxif the iterator emits less thanmaxelements).- Parameters:
i- a type-specific iterator.c- a type-specific collection array to contain the output of the iterator.max- the maximum number of elements to unwrap.- Returns:
- the number of elements unwrapped. Note that this is the number of elements returned by the iterator, which is not necessarily the number of elements that have been added to the collection (because of duplicates).
-
unwrapBig
public static float[][] unwrapBig(it.unimi.dsi.fastutil.floats.FloatIterator i, long max)Unwraps an iterator, returning a big array, with a limit on the number of elements.This method iterates over the given type-specific iterator and returns a big array containing the elements returned by the iterator. At most
maxelements will be returned.- Parameters:
i- a type-specific iterator.max- the maximum number of elements to be unwrapped.- Returns:
- a big array containing the elements returned by the iterator (at most
max).
-
unwrapBig
public static float[][] unwrapBig(it.unimi.dsi.fastutil.floats.FloatIterator i)Unwraps an iterator, returning a big array.This method iterates over the given type-specific iterator and returns a big array containing the elements returned by the iterator.
- Parameters:
i- a type-specific iterator.- Returns:
- a big array containing the elements returned by the iterator.
-
unwrap
Unwraps an iterator into a type-specific collection.This method iterates over the given type-specific iterator and stores the elements returned in the given type-specific collection. The returned count on the number unwrapped elements is a long, so that it will work also with very large collections.
- Parameters:
i- a type-specific iterator.c- a type-specific collection to contain the output of the iterator.- Returns:
- the number of elements unwrapped. Note that this is the number of elements returned by the iterator, which is not necessarily the number of elements that have been added to the collection (because of duplicates).
-
pour
Pours an iterator into a type-specific collection, with a limit on the number of elements.This method iterates over the given type-specific iterator and adds the returned elements to the given collection (up to
max).- Parameters:
i- a type-specific iterator.s- a type-specific collection.max- the maximum number of elements to be poured.- Returns:
- the number of elements poured. Note that this is the number of elements returned by the iterator, which is not necessarily the number of elements that have been added to the collection (because of duplicates).
-
pour
Pours an iterator into a type-specific collection.This method iterates over the given type-specific iterator and adds the returned elements to the given collection.
- Parameters:
i- a type-specific iterator.s- a type-specific collection.- Returns:
- the number of elements poured. Note that this is the number of elements returned by the iterator, which is not necessarily the number of elements that have been added to the collection (because of duplicates).
-
pour
Pours an iterator, returning a type-specific list, with a limit on the number of elements.This method iterates over the given type-specific iterator and returns a type-specific list containing the returned elements (up to
max). Iteration on the returned list is guaranteed to produce the elements in the same order in which they appeared in the iterator.- Parameters:
i- a type-specific iterator.max- the maximum number of elements to be poured.- Returns:
- a type-specific list containing the returned elements, up to
max.
-
pour
Pours an iterator, returning a type-specific list.This method iterates over the given type-specific iterator and returns a list containing the returned elements. Iteration on the returned list is guaranteed to produce the elements in the same order in which they appeared in the iterator.
- Parameters:
i- a type-specific iterator.- Returns:
- a type-specific list containing the returned elements.
-
asFloatIterator
public static it.unimi.dsi.fastutil.floats.FloatIterator asFloatIterator(java.util.Iterator i)Wraps a standard iterator into a type-specific iterator.This method wraps a standard iterator into a type-specific one which will handle the type conversions for you. Of course, any attempt to wrap an iterator returning the instances of the wrong class will generate a
ClassCastException. The returned iterator is backed byi: changes to one of the iterators will affect the other, too.- Parameters:
i- an iterator.- Returns:
- a type-specific iterator backed by
i. - Implementation Notes:
- If
iis already type-specific, it will returned and no new object will be generated.
-
narrow
public static it.unimi.dsi.fastutil.floats.FloatIterator narrow(java.util.PrimitiveIterator.OfDouble i)Wrap a JDK primitive iterator to a type-specific iterator, making checked narrowed casts.- Parameters:
i- an iterator.- Returns:
- a type-specific iterator backed by
i. - Since:
- 8.5.0
- Implementation Notes:
- The
nextmethod throwsIllegalArgumentExceptionif any element would underflow or overflow.
-
uncheckedNarrow
public static it.unimi.dsi.fastutil.floats.FloatIterator uncheckedNarrow(java.util.PrimitiveIterator.OfDouble i)Wrap a JDK primitive iterator to a type-specific iterator, making unchecked narrowing casts.No test is done for overflow or underflow.
- Parameters:
i- an iterator.- Returns:
- a type-specific iterator backed by
i. - Since:
- 8.5.0
-
widen
public static it.unimi.dsi.fastutil.doubles.DoubleIterator widen(it.unimi.dsi.fastutil.floats.FloatIterator i)Wrap a type-specific iterator to a JDK compatible primitive iterator.- Parameters:
i- an iterator- Returns:
- a JDK compatible primitive iterator backed by
i - Since:
- 8.5.0
-
asFloatIterator
Wraps a standard list iterator into a type-specific list iterator.This method wraps a standard list iterator into a type-specific one which will handle the type conversions for you. Of course, any attempt to wrap an iterator returning the instances of the wrong class will generate a
ClassCastException. The returned iterator is backed byi: changes to one of the iterators will affect the other, too.If
iis already type-specific, it will returned and no new object will be generated.- Parameters:
i- a list iterator.- Returns:
- a type-specific list iterator backed by
i.
-
any
public static boolean any(it.unimi.dsi.fastutil.floats.FloatIterator iterator, FloatPredicate predicate)Returns whether an element returned by the given iterator satisfies the given predicate.Short circuit evaluation is performed; the first
truefrom the predicate terminates the loop.- Returns:
- true if an element returned by
iteratorsatisfiespredicate.
-
any
public static boolean any(it.unimi.dsi.fastutil.floats.FloatIterator iterator, java.util.function.DoublePredicate predicate)Returns whether an element returned by the given iterator satisfies the given predicate.Short circuit evaluation is performed; the first
truefrom the predicate terminates the loop.- Returns:
- true if an element returned by
iteratorsatisfiespredicate. lambda to perform widening casts. Please use the type-specific overload to avoid this overhead.
-
all
public static boolean all(it.unimi.dsi.fastutil.floats.FloatIterator iterator, FloatPredicate predicate)Returns whether all elements returned by the given iterator satisfy the given predicate.Short circuit evaluation is performed; the first
falsefrom the predicate terminates the loop.- Returns:
- true if all elements returned by
iteratorsatisfypredicate.
-
all
public static boolean all(it.unimi.dsi.fastutil.floats.FloatIterator iterator, java.util.function.DoublePredicate predicate)Returns whether all elements returned by the given iterator satisfy the given predicate.Short circuit evaluation is performed; the first
falsefrom the predicate terminates the loop.- Returns:
- true if all elements returned by
iteratorsatisfypredicate. - Implementation Notes:
- Unless the argument is type-specific, this method will introduce an intermediary lambda to perform widening casts. Please use the type-specific overload to avoid this overhead.
-
indexOf
public static int indexOf(it.unimi.dsi.fastutil.floats.FloatIterator iterator, FloatPredicate predicate)Returns the index of the first element returned by the given iterator that satisfies the given predicate, or −1 if no such element was found.The next element returned by the iterator always considered element 0, even for
ListIterators. In other wordsListIterator.nextIndexis ignored.- Returns:
- the index of the first element returned by
iteratorthat satisfiespredicate, or −1 if no such element was found.
-
indexOf
public static int indexOf(it.unimi.dsi.fastutil.floats.FloatIterator iterator, java.util.function.DoublePredicate predicate)Returns the index of the first element returned by the given iterator that satisfies the given predicate, or −1 if no such element was found.The next element returned by the iterator always considered element 0, even for
ListIterators. In other wordsListIterator.nextIndexis ignored.- Returns:
- the index of the first element returned by
iteratorthat satisfiespredicate, or −1 if no such element was found. - Implementation Notes:
- Unless the argument is type-specific, this method will introduce an intermediary lambda to perform widening casts. Please use the type-specific overload to avoid this overhead.
-
concat
public static it.unimi.dsi.fastutil.floats.FloatIterator concat(it.unimi.dsi.fastutil.floats.FloatIterator... a)Concatenates all iterators contained in an array.This method returns an iterator that will enumerate in order the elements returned by all iterators contained in the given array.
- Parameters:
a- an array of iterators.- Returns:
- an iterator obtained by concatenation.
-
concat
public static it.unimi.dsi.fastutil.floats.FloatIterator concat(it.unimi.dsi.fastutil.floats.FloatIterator[] a, int offset, int length)Concatenates a sequence of iterators contained in an array.This method returns an iterator that will enumerate in order the elements returned by
a[offset], then those returned bya[offset + 1], and so on up toa[offset + length - 1].- Parameters:
a- an array of iterators.offset- the index of the first iterator to concatenate.length- the number of iterators to concatenate.- Returns:
- an iterator obtained by concatenation of
lengthelements ofastarting atoffset.
-
unmodifiable
public static it.unimi.dsi.fastutil.floats.FloatIterator unmodifiable(it.unimi.dsi.fastutil.floats.FloatIterator i)Returns an unmodifiable iterator backed by the specified iterator.- Parameters:
i- the iterator to be wrapped in an unmodifiable iterator.- Returns:
- an unmodifiable view of the specified iterator.
-
unmodifiable
Returns an unmodifiable bidirectional iterator backed by the specified bidirectional iterator.- Parameters:
i- the bidirectional iterator to be wrapped in an unmodifiable bidirectional iterator.- Returns:
- an unmodifiable view of the specified bidirectional iterator.
-
unmodifiable
Returns an unmodifiable list iterator backed by the specified list iterator.- Parameters:
i- the list iterator to be wrapped in an unmodifiable list iterator.- Returns:
- an unmodifiable view of the specified list iterator.
-
wrap
public static it.unimi.dsi.fastutil.floats.FloatIterator wrap(it.unimi.dsi.fastutil.bytes.ByteIterator iterator)Returns an iterator backed by the specified byte iterator.- Parameters:
iterator- a byte iterator.- Returns:
- an iterator backed by the specified byte iterator.
-
wrap
public static it.unimi.dsi.fastutil.floats.FloatIterator wrap(it.unimi.dsi.fastutil.shorts.ShortIterator iterator)Returns an iterator backed by the specified short iterator.- Parameters:
iterator- a short iterator.- Returns:
- an iterator backed by the specified short iterator.
-
wrap
public static it.unimi.dsi.fastutil.floats.FloatIterator wrap(it.unimi.dsi.fastutil.chars.CharIterator iterator)Returns an iterator backed by the specified char iterator.WARNING: This is not the same as converting the source to a sequence of code points. This returned instance literally performs
(int)(charValue)casts. Surrogate pairs will be left as separate elements instead of combined into a single element with the code point it represents. SeeCharacterfor more discussion on code points, char values, and surrogate pairs.- Parameters:
iterator- a char iterator.- Returns:
- an iterator backed by the specified char iterator.
-