Package org.eclipse.epsilon.common.util
Class SizeCachingConcurrentQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- java.util.concurrent.ConcurrentLinkedQueue<E>
-
- org.eclipse.epsilon.common.util.SizeCachingConcurrentQueue<E>
-
- Type Parameters:
E
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Queue<E>
public class SizeCachingConcurrentQueue<E> extends java.util.concurrent.ConcurrentLinkedQueue<E>
AConcurrentLinkedQueue
wrapper which supportsnull
values using a constant wrapper in place of null elements. This implementation caches the size and updates it when structurally modified to avoid the issue outlined in Java Specialists Issue 261.- Since:
- 1.6
- Author:
- Sina Madani
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.Object
NULL
protected java.util.function.Consumer<? extends E>
offerSuper
protected java.util.concurrent.atomic.AtomicInteger
size
-
Constructor Summary
Constructors Constructor Description SizeCachingConcurrentQueue()
SizeCachingConcurrentQueue(java.util.Collection<? extends E> initial)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addAll(java.util.Collection<? extends E> c)
boolean
contains(java.lang.Object o)
static <T> T
convertToNull(java.lang.Object o)
boolean
equals(java.lang.Object o)
int
hashCode()
java.util.Iterator<E>
iterator()
boolean
offer(E e)
E
peek()
E
poll()
boolean
remove(java.lang.Object o)
protected static java.lang.Object
replaceWithNull(java.lang.Object o)
int
size()
-
Methods inherited from class java.util.concurrent.ConcurrentLinkedQueue
add, clear, forEach, isEmpty, removeAll, removeIf, retainAll, spliterator, toArray, toArray, toString
-
-
-
-
Field Detail
-
NULL
protected static final java.lang.Object NULL
-
size
protected final java.util.concurrent.atomic.AtomicInteger size
-
offerSuper
protected final java.util.function.Consumer<? extends E> offerSuper
-
-
Constructor Detail
-
SizeCachingConcurrentQueue
public SizeCachingConcurrentQueue()
-
SizeCachingConcurrentQueue
public SizeCachingConcurrentQueue(java.util.Collection<? extends E> initial)
-
-
Method Detail
-
replaceWithNull
protected static final java.lang.Object replaceWithNull(java.lang.Object o)
-
convertToNull
public static final <T> T convertToNull(java.lang.Object o)
-
peek
public E peek()
-
poll
public E poll()
-
offer
public boolean offer(E e)
-
addAll
public boolean addAll(java.util.Collection<? extends E> c)
-
remove
public boolean remove(java.lang.Object o)
-
size
public int size()
-
iterator
public java.util.Iterator<E> iterator()
-
contains
public boolean contains(java.lang.Object o)
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfacejava.util.Collection<E>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<E>
- Overrides:
hashCode
in classjava.lang.Object
-
-