|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectthread.Deque
public class Deque
This Deque class implements a double ended queue in a
similar way as the class BoundedBuffer does.
It has some capacity to store objects.
With the method put
objects are placed into
the buffer. With the get
method objects are taken
from the buffer in FIFO order and with pop
objects
are taken from the buffer in LIFO order.
put
blocks if there is no space to
place a object into the buffer.
get
and pop
block if there are
no objects in the channel.
This class is safe against Thread InterruptedException.
see Channel
see Queue
see Deque
see MemoryChannel
see SyncChannel
see Stack
,
Serialized FormField Summary | |
---|---|
private java.lang.Object[] |
buffer
the buffer is the deque contents. |
private Semaphore |
empty
a semaphore indicating an empty cell. |
private int |
front
index to the first filled cell. |
private Semaphore |
full
a semaphore indicating a filled cell. |
private java.lang.Object |
rcv
mutex for receive. |
private int |
rear
index to the first empty cell. |
private int |
size
the buffer's size. |
private java.lang.Object |
snd
mutex for send. |
static java.lang.String |
undefined
Declares an undefined value of type String . |
Constructor Summary | |
---|---|
Deque(int init)
Construct a Deque. |
Method Summary | |
---|---|
boolean |
empty()
Tests if the deque is empty. |
java.lang.Object |
get()
Get an object from the deque, FIFO order. |
java.lang.Object |
get(int m)
Get an object from the deque within given timeout, FIFO order. |
java.lang.Object |
pop()
Pop an object from the deque, LIFO order. |
java.lang.Object |
pop(int m)
Pop an object from the deque within given timeout, LIFO order. |
void |
push(java.lang.Object v)
Push an object to the deque. |
void |
put(java.lang.Object v)
Put an object to the deque. |
int |
size()
Get the number of elements in the deque. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.Object[] buffer
private int size
private int front
private int rear
private Semaphore empty
private Semaphore full
private java.lang.Object snd
private java.lang.Object rcv
public static final java.lang.String undefined
String
.
Constructor Detail |
---|
public Deque(int init)
init
- An integer which defines the deques size.Method Detail |
---|
public void put(java.lang.Object v) throws java.lang.InterruptedException
InterruptedException.
java.lang.InterruptedException
public void push(java.lang.Object v) throws java.lang.InterruptedException
InterruptedException.
java.lang.InterruptedException
public java.lang.Object get() throws java.lang.InterruptedException
InterruptedException.
java.lang.InterruptedException
public java.lang.Object get(int m) throws java.lang.InterruptedException
InterruptedException.
java.lang.InterruptedException
public java.lang.Object pop() throws java.lang.InterruptedException
InterruptedException.
java.lang.InterruptedException
public java.lang.Object pop(int m) throws java.lang.InterruptedException
InterruptedException.
java.lang.InterruptedException
public boolean empty()
public int size()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |