Package uk.ac.starlink.vo
Class LinkedBlockingStack<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- uk.ac.starlink.vo.LinkedBlockingStack<E>
-
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.concurrent.BlockingQueue<E>,java.util.Queue<E>
public class LinkedBlockingStack<E> extends java.util.AbstractQueue<E> implements java.util.concurrent.BlockingQueue<E>An unbounded LIFO BlockingQueue. Implemented as a simple singly-linked list protected by a ReentrantLock, with a Condition to manage waiting for elements in take().
-
-
Constructor Summary
Constructors Constructor Description LinkedBlockingStack()LinkedBlockingStack(java.util.Collection c)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontains(java.lang.Object o)intdrainTo(java.util.Collection c)intdrainTo(java.util.Collection c, int max)protected java.util.concurrent.locks.ReentrantLockgetLock()Returns the lock object used for synchronizing this object's state.java.util.Iterator<E>iterator()booleanoffer(E o)booleanoffer(E o, long t, java.util.concurrent.TimeUnit unit)Epeek()Epoll()Epoll(long t, java.util.concurrent.TimeUnit unit)voidput(E o)intremainingCapacity()booleanremove(java.lang.Object o)intsize()Etake()-
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
getLock
protected java.util.concurrent.locks.ReentrantLock getLock()
Returns the lock object used for synchronizing this object's state.
-
size
public int size()
-
offer
public boolean offer(E o)
-
offer
public boolean offer(E o, long t, java.util.concurrent.TimeUnit unit)
- Specified by:
offerin interfacejava.util.concurrent.BlockingQueue<E>
-
take
public E take() throws java.lang.InterruptedException
- Specified by:
takein interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
poll
public E poll(long t, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
pollin interfacejava.util.concurrent.BlockingQueue<E>- Throws:
java.lang.InterruptedException
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacityin interfacejava.util.concurrent.BlockingQueue<E>
-
contains
public boolean contains(java.lang.Object o)
-
remove
public boolean remove(java.lang.Object o)
-
clear
public void clear()
-
drainTo
public int drainTo(java.util.Collection c)
- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
public int drainTo(java.util.Collection c, int max)- Specified by:
drainToin interfacejava.util.concurrent.BlockingQueue<E>
-
-