java.lang.Object
edu.iu.IuEnumerableQueue<T>
- Type Parameters:
T
- element type
- All Implemented Interfaces:
Iterable<T>
,Enumeration<T>
,BooleanSupplier
,Consumer<T>
,Iterator<T>
,Spliterator<T>
public class IuEnumerableQueue<T>
extends Object
implements Consumer<T>, BooleanSupplier, Enumeration<T>, Iterator<T>, Spliterator<T>, Iterable<T>
Implements a simple non-blocking FIFO queue based on the
Consumer
,
and Enumeration
, and BooleanSupplier
interfaces.
In this scenario, getAsBoolean()
, hasNext()
, and
hasMoreElements()
are synonymous.
This class is thread-safe and intended for use in high-volume parallel processing scenarios.
For blocking behavior, use
IuObject.waitFor(Object, BooleanSupplier, java.time.Duration)
or
IuObject.waitFor(Object, BooleanSupplier, java.time.Instant)
as in
the example below:
IuObject.waitFor(enumerableQueue, enumerableQueue, Duration.ofSeconds(5L));
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.Spliterator
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,
T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>> -
Field Summary
Fields inherited from interface java.util.Spliterator
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ConstructorConstructorConstructorConstructorIuEnumerableQueue
(Stream<T> e) Constructor -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Spliterator
getComparator, getExactSizeIfKnown, hasCharacteristics
-
Constructor Details
-
IuEnumerableQueue
public IuEnumerableQueue()Default constructor. -
IuEnumerableQueue
Constructor- Parameters:
e
- supplies initial values
-
IuEnumerableQueue
Constructor- Parameters:
e
- supplies initial values
-
IuEnumerableQueue
Constructor- Parameters:
e
- supplies initial values
-
IuEnumerableQueue
Constructor- Parameters:
e
- supplies initial values
-
IuEnumerableQueue
Constructor- Parameters:
e
- supplies initial values
-
-
Method Details
-
accept
-
getAsBoolean
public boolean getAsBoolean()- Specified by:
getAsBoolean
in interfaceBooleanSupplier
-
hasMoreElements
public boolean hasMoreElements()- Specified by:
hasMoreElements
in interfaceEnumeration<T>
-
hasNext
public boolean hasNext() -
next
-
nextElement
- Specified by:
nextElement
in interfaceEnumeration<T>
-
tryAdvance
- Specified by:
tryAdvance
in interfaceSpliterator<T>
-
trySplit
- Specified by:
trySplit
in interfaceSpliterator<T>
-
estimateSize
public long estimateSize()- Specified by:
estimateSize
in interfaceSpliterator<T>
-
characteristics
public int characteristics()- Specified by:
characteristics
in interfaceSpliterator<T>
-
forEachRemaining
- Specified by:
forEachRemaining
in interfaceIterator<T>
- Specified by:
forEachRemaining
in interfaceSpliterator<T>
-
iterator
-
asIterator
- Specified by:
asIterator
in interfaceEnumeration<T>
-
stream
Gets aStream
of queued elements.- Returns:
Stream
-
parallelStream
Gets a parallelStream
of queued elements.- Returns:
Stream
-