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:
Serializable
,Iterable<E>
,Collection<E>
,Queue<E>
public class SizeCachingConcurrentQueue<E> extends 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 Object
NULL
protected Consumer<? extends E>
offerSuper
protected AtomicInteger
size
-
Constructor Summary
Constructors Constructor Description SizeCachingConcurrentQueue()
SizeCachingConcurrentQueue(Collection<? extends E> initial)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addAll(Collection<? extends E> c)
boolean
contains(Object o)
static <T> T
convertToNull(Object o)
boolean
equals(Object o)
int
hashCode()
Iterator<E>
iterator()
boolean
offer(E e)
E
peek()
E
poll()
boolean
remove(Object o)
protected static Object
replaceWithNull(Object o)
int
size()
-
Methods inherited from class java.util.concurrent.ConcurrentLinkedQueue
add, clear, forEach, isEmpty, removeAll, removeIf, retainAll, spliterator, toArray, toArray, toString
-
Methods inherited from class java.util.AbstractQueue
element, remove
-
Methods inherited from class java.util.AbstractCollection
containsAll
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
containsAll, parallelStream, stream, toArray
-
-
-
-
Field Detail
-
NULL
protected static final Object NULL
-
size
protected final AtomicInteger size
-
-
Constructor Detail
-
SizeCachingConcurrentQueue
public SizeCachingConcurrentQueue()
-
SizeCachingConcurrentQueue
public SizeCachingConcurrentQueue(Collection<? extends E> initial)
-
-
Method Detail
-
convertToNull
public static final <T> T convertToNull(Object o)
-
peek
public E peek()
-
poll
public E poll()
-
offer
public boolean offer(E e)
-
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll
in interfaceCollection<E>
- Overrides:
addAll
in classConcurrentLinkedQueue<E>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<E>
- Overrides:
remove
in classConcurrentLinkedQueue<E>
-
size
public int size()
- Specified by:
size
in interfaceCollection<E>
- Overrides:
size
in classConcurrentLinkedQueue<E>
-
iterator
public Iterator<E> iterator()
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Overrides:
iterator
in classConcurrentLinkedQueue<E>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<E>
- Overrides:
contains
in classConcurrentLinkedQueue<E>
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<E>
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<E>
- Overrides:
hashCode
in classObject
-
-