Package org.vibur.objectpool.util
Interface ConcurrentCollection<T>
- Type Parameters:
T- the type of objects held in thisConcurrentCollection
- All Known Implementing Classes:
ConcurrentLinkedDequeCollection,ConcurrentLinkedQueueCollection,ConcurrentStackCollection,MultithreadConcurrentQueueCollection
public interface ConcurrentCollection<T>
An adapter interface to a concurrent collection that provides 4 access methods:
offerFirst(T),
offerLast(T), pollFirst(), and pollLast(). If the implementing subclass delegates the above
methods to a Collection that does not have native implementation for offerFirst() or pollLast()
it can implement these methods in the same way as offerLast() or pollFirst(), and the vice versa.- Author:
- Simeon Malchev
-
Method Summary
Modifier and TypeMethodDescriptionvoidofferFirst(T object) Adds the givenobjectat the head of theConcurrentCollection.voidAdds the givenobjectat the tail of theConcurrentCollection.Polls anobjectfrom the head of theConcurrentCollection.pollLast()Polls anobjectfrom the tail of theConcurrentCollection.intsize()Returns the number of elements in this collection.
-
Method Details
-
offerFirst
Adds the givenobjectat the head of theConcurrentCollection.- Parameters:
object- the given object
-
offerLast
Adds the givenobjectat the tail of theConcurrentCollection.- Parameters:
object- the given object
-
pollFirst
T pollFirst()Polls anobjectfrom the head of theConcurrentCollection.- Returns:
- the head Collection object if available;
nullotherwise
-
pollLast
T pollLast()Polls anobjectfrom the tail of theConcurrentCollection.- Returns:
- the tail Collection object if available;
nullotherwise
-
size
int size()Returns the number of elements in this collection.- Returns:
- the number of elements in this collection
-