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>
AConcurrentLinkedQueuewrapper which supportsnullvalues 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 ObjectNULLprotected Consumer<? extends E>offerSuperprotected AtomicIntegersize
-
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 booleanaddAll(Collection<? extends E> c)booleancontains(Object o)static <T> TconvertToNull(Object o)booleanequals(Object o)inthashCode()Iterator<E>iterator()booleanoffer(E e)Epeek()Epoll()booleanremove(Object o)protected static ObjectreplaceWithNull(Object o)intsize()-
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:
addAllin interfaceCollection<E>- Overrides:
addAllin classConcurrentLinkedQueue<E>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<E>- Overrides:
removein classConcurrentLinkedQueue<E>
-
size
public int size()
- Specified by:
sizein interfaceCollection<E>- Overrides:
sizein classConcurrentLinkedQueue<E>
-
iterator
public Iterator<E> iterator()
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Overrides:
iteratorin classConcurrentLinkedQueue<E>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<E>- Overrides:
containsin classConcurrentLinkedQueue<E>
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceCollection<E>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<E>- Overrides:
hashCodein classObject
-
-