public class QList
extends java.lang.Object
Constructor and Description |
---|
QList(java.lang.String name,
int capacity)
initialzes a queue with capacity of cells
|
Modifier and Type | Method and Description |
---|---|
int |
add(java.lang.Object obj,
int id)
adds a new object to the cell with the id and returns the depth of the
queue upon success or -1 to indicate failure.
|
java.lang.Object |
browse(int id)
returns the object in the cell with the id or null if id is out of bound.
|
Browser |
browser()
returns an instance of Browser for ids of occupied cells
|
int |
cancel(int id)
cancels the reservation on the cell with the id and returns the
watermark upon success or -1 otherwise.
|
void |
clear()
clear all cells and reset all marks
|
int |
collect()
collects the next collectible cell so that it is ready to be reserved
|
int |
collect(int id)
collects the id-th cell so that it is ready to be reserved.
|
int |
collectible()
returns the number of collectible objects in the queue
|
int |
depth()
returns the number of new objects in the queue
|
protected void |
finalize() |
int |
getCapacity() |
java.lang.String |
getName() |
int |
getNextID()
returns the id of the next occupied cell or -1 if there is none of
the occupied cells available.
|
int |
getNextID(int id)
verifies the occupency on the cell with the id and returns the id if it
is occupied or -1 otherwise.
|
int |
getType(int id)
returns the type of the cell with the id if it is not out of bound
or -1 otherwise
|
boolean |
isFull() |
int |
putback(int id)
puts an in-use object back to the cell with the id and returns the depth
of the queue upon success or -1 otherwise.
|
int |
queryIDs(int[] ids,
int type)
loads the ids of the type of cells in the natual order to the given array
|
java.lang.Object |
remove(int id)
removes the in-use object from the cell with the id and returns the
original object upon success or null otherwise.
|
int |
reserve()
reserves the empty cell with the id and returns the id upon success or -1
otherwise.
|
int |
reserve(int id)
reserves an empty cell in the range of len cells starting from begin
and returns the id of the cell upon success or -1 otherwise.
|
int |
rotate(int id)
rotates the object with the id to the end of the list and returns 1 for
success, 0 for failure or -1 for out of bound.
|
int |
size()
returns the number of objects in the queue, new and in-use
|
int |
swap(int id,
int jd)
swaps the positions between the two occupied cells referenced by their
ids and returns 1 for success, 0 for failure or -1 for out of bound.
|
java.lang.Object |
takeback(int id)
takes back the new object in the cell with the id and sets the cell
EMPTY again.
|
public QList(java.lang.String name, int capacity)
public java.lang.String getName()
public int size()
public int depth()
public int collectible()
public int getCapacity()
public boolean isFull()
public int getType(int id)
public int collect()
public int collect(int id)
public int reserve()
public int reserve(int id)
public int cancel(int id)
public int add(java.lang.Object obj, int id)
public java.lang.Object takeback(int id)
public int getNextID()
public int getNextID(int id)
public java.lang.Object browse(int id)
public int putback(int id)
public java.lang.Object remove(int id)
public int swap(int id, int jd)
public int rotate(int id)
public int queryIDs(int[] ids, int type)
public Browser browser()
public void clear()
protected void finalize()
finalize
in class java.lang.Object