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 void
clear()
boolean
contains(java.lang.Object o)
int
drainTo(java.util.Collection c)
int
drainTo(java.util.Collection c, int max)
protected java.util.concurrent.locks.ReentrantLock
getLock()
Returns the lock object used for synchronizing this object's state.java.util.Iterator<E>
iterator()
boolean
offer(E o)
boolean
offer(E o, long t, java.util.concurrent.TimeUnit unit)
E
peek()
E
poll()
E
poll(long t, java.util.concurrent.TimeUnit unit)
void
put(E o)
int
remainingCapacity()
boolean
remove(java.lang.Object o)
int
size()
E
take()
-
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:
offer
in interfacejava.util.concurrent.BlockingQueue<E>
-
take
public E take() throws java.lang.InterruptedException
- Specified by:
take
in 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:
poll
in interfacejava.util.concurrent.BlockingQueue<E>
- Throws:
java.lang.InterruptedException
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacity
in 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:
drainTo
in interfacejava.util.concurrent.BlockingQueue<E>
-
drainTo
public int drainTo(java.util.Collection c, int max)
- Specified by:
drainTo
in interfacejava.util.concurrent.BlockingQueue<E>
-
-