Interface DoubleIterable
-
- All Superinterfaces:
java.lang.Iterable<java.lang.Double>
- All Known Subinterfaces:
DoubleBidirectionalIterable
,DoubleBigList
,DoubleCollection
,DoubleList
,DoubleSet
,DoubleSortedSet
- All Known Implementing Classes:
AbstractDoubleBigList
,AbstractDoubleBigList.DoubleRandomAccessSubList
,AbstractDoubleBigList.DoubleSubList
,AbstractDoubleCollection
,AbstractDoubleList
,AbstractDoubleList.DoubleRandomAccessSubList
,AbstractDoubleList.DoubleSubList
,AbstractDoubleSet
,AbstractDoubleSortedSet
,DoubleArrayList
,DoubleArraySet
,DoubleAVLTreeSet
,DoubleBigArrayBigList
,DoubleBigLists.EmptyBigList
,DoubleBigLists.ListBigList
,DoubleBigLists.Singleton
,DoubleBigLists.SynchronizedBigList
,DoubleBigLists.UnmodifiableBigList
,DoubleCollections.EmptyCollection
,DoubleCollections.IterableCollection
,DoubleImmutableList
,DoubleLinkedOpenCustomHashSet
,DoubleLinkedOpenHashSet
,DoubleLists.EmptyList
,DoubleLists.Singleton
,DoubleLists.SynchronizedList
,DoubleLists.SynchronizedRandomAccessList
,DoubleLists.UnmodifiableList
,DoubleLists.UnmodifiableRandomAccessList
,DoubleOpenCustomHashSet
,DoubleOpenHashBigSet
,DoubleOpenHashSet
,DoubleRBTreeSet
,DoubleSets.EmptySet
,DoubleSets.Singleton
,DoubleSets.SynchronizedSet
,DoubleSets.UnmodifiableSet
,DoubleSortedSets.EmptySet
,DoubleSortedSets.Singleton
,DoubleSortedSets.SynchronizedSortedSet
,DoubleSortedSets.UnmodifiableSortedSet
public interface DoubleIterable extends java.lang.Iterable<java.lang.Double>
A type-specificIterable
that strengthens that specification ofiterator()
andforEach(Consumer)
.Note that whenever there exist a primitive consumer in
java.util.function
(e.g.,IntConsumer
), trying to access any version offorEach(Consumer)
using a lambda expression with untyped arguments will generate an ambiguous method error. This can be easily solved by specifying the type of the argument, as inintIterable.forEach((int x) -> { // Do something with x });
The same problem plagues, for example,
PrimitiveIterator.OfInt.forEachRemaining(java.util.function.IntConsumer)
.Warning: Java will let you write “colon”
for
statements with primitive-type loop variables; however, what is (unfortunately) really happening is that at each iteration an unboxing (and, in the case offastutil
type-specific data structures, a boxing) will be performed. Watch out.- See Also:
Iterable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default DoubleIterator
doubleIterator()
Returns a primitive iterator on the elements of this iterable.default DoubleSpliterator
doubleSpliterator()
Returns a primitive spliterator on the elements of this iterable.default void
forEach(DoubleConsumer action)
Performs the given action for each element of this type-specificIterable
until all elements have been processed or the action throws an exception.default void
forEach(java.util.function.Consumer<? super java.lang.Double> action)
Deprecated.Please use the corresponding type-specific method instead.default void
forEach(java.util.function.DoubleConsumer action)
Performs the given action for each element of this type-specificIterable
until all elements have been processed or the action throws an exception.DoubleIterator
iterator()
Returns a type-specific iterator.default DoubleSpliterator
spliterator()
Returns a type-specific spliterator on the elements of this iterable.
-
-
-
Method Detail
-
iterator
DoubleIterator iterator()
Returns a type-specific iterator.- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Double>
- Returns:
- a type-specific iterator.
- See Also:
Iterable.iterator()
- API Notes:
- Note that this specification strengthens the one given in
Iterable.iterator()
.
-
doubleIterator
default DoubleIterator doubleIterator()
Returns a primitive iterator on the elements of this iterable.This method is identical to
iterator()
, as the type-specific iterator is already compatible with the JDK's primitive iterators. It only exists for compatibility with the other primitive types'Iterable
s that have use for widened iterators.- Returns:
- a primitive iterator on the elements of this iterable.
- Since:
- 8.5.0
-
spliterator
default DoubleSpliterator spliterator()
Returns a type-specific spliterator on the elements of this iterable.- Specified by:
spliterator
in interfacejava.lang.Iterable<java.lang.Double>
- Returns:
- a type-specific spliterator on the elements of this iterable.
- Since:
- 8.5.0
- API Notes:
- Note that this specification strengthens the one given in
Iterable.spliterator()
.
-
doubleSpliterator
default DoubleSpliterator doubleSpliterator()
Returns a primitive spliterator on the elements of this iterable.This method is identical to
spliterator()
, as the type-specific spliterator is already compatible with the JDK's primitive spliterators. It only exists for compatibility with the other primitive types'Iterable
s that have use for widened spliterators.- Returns:
- a primitive spliterator on the elements of this collection.
- Since:
- 8.5.0
-
forEach
default void forEach(java.util.function.DoubleConsumer action)
Performs the given action for each element of this type-specificIterable
until all elements have been processed or the action throws an exception.- Parameters:
action
- the action to be performed for each element.- Since:
- 8.0.0
- See Also:
Iterable.forEach(java.util.function.Consumer)
- API Notes:
- Implementing classes should generally override this method, and take the default implementation of the other overloads which will delegate to this method (after proper conversions).
-
forEach
default void forEach(DoubleConsumer action)
Performs the given action for each element of this type-specificIterable
until all elements have been processed or the action throws an exception.WARNING: Overriding this method is almost always a mistake, as this overload only exists to disambiguate. Instead, override the
forEach()
overload that uses the JDK's primitive consumer type (e.g.IntConsumer
).If Java supported final default methods, this would be one, but sadly it does not.
If you checked and are overriding the version with
java.util.function.XConsumer
, and still see this warning, then your IDE is incorrectly conflating this method with the proper method to override, and you can safely ignore this message.- Parameters:
action
- the action to be performed for each element.- Since:
- 8.5.0
- See Also:
Iterable.forEach(java.util.function.Consumer)
-
forEach
@Deprecated default void forEach(java.util.function.Consumer<? super java.lang.Double> action)
Deprecated.Please use the corresponding type-specific method instead.- Specified by:
forEach
in interfacejava.lang.Iterable<java.lang.Double>
-
-