|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.util.PriorityQueue
Vector of prioritized objects.
A PriorityQueue
is vector of prioritized Objects.
Constructor Summary | |
PriorityQueue()
Initializes an empty PriorityQueue , using a default initial capacity. |
|
PriorityQueue(int cap)
Prepares an empty PriorityQueue with the specified initial capacity. |
Method Summary | |
void |
addElement(java.lang.Object object)
Adds an element to the end of this queue, using the priority of the last Object in the queue. |
int |
capacity()
Returns the current capacity of this queue. |
java.lang.Object |
clone()
Clones this queue. |
boolean |
contains(java.lang.Object obj)
Tells if this queue contains the specified object. |
void |
copyInto(java.lang.Object[] dest)
Copies elements into Object array. |
java.lang.Object |
elementAt(int index)
Returns the element at the specified index in the queue. |
void |
ensureCapacity(int capacity)
Guarantees that this queue will be able to buffer at least the indicated number of elements. |
java.lang.Object |
firstElement()
Returns the next element in the queue without removing it. |
boolean |
hasMoreElements()
Determines whether this queue contains more elements. |
int |
indexOf(java.lang.Object obj)
See indexOf(Object,int) . |
int |
indexOf(java.lang.Object obj,
int index)
Searches this queue for an object equal to the given object. |
void |
insertElementAt(java.lang.Object obj,
int index)
Inserts an object into the queue. |
void |
insertPrioritizedElement(java.lang.Object obj,
int priority)
Inserts an object into the queue at the end of other objects with the same or higher priority. |
boolean |
isEmpty()
Determines if this queue is empty. |
java.lang.Object |
lastElement()
Returns the last element in this queue without removing it. |
int |
lastIndexOf(java.lang.Object obj)
See lastIndexOf(Object,int) . |
int |
lastIndexOf(java.lang.Object obj,
int index)
Searches this queue for an object equal to the given object. |
java.lang.Object |
nextElement()
Removes the element at the head of the queue and returns it. |
int |
priorityAt(int index)
Copies elements into Object array. |
void |
removeAllElements()
Empties the queue. |
boolean |
removeElement(java.lang.Object obj)
Removes the specified object from the queue. |
void |
removeElementAt(int index)
Deletes the element at the specified index. |
void |
setElementAt(java.lang.Object obj,
int index)
Replaces the element at the specified index with the given object. |
void |
setSize(int new_size)
Sets the number of elements contained in this queue. |
int |
size()
Returns the number of elements currently buffered in this queue. |
java.lang.String |
toString()
Generates a string representation of this queue. |
void |
trimToSize()
Minimizes the amount of memory used to store this queue. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public PriorityQueue(int cap)
PriorityQueue
with the specified initial capacity.dc
- the initial capacitypublic PriorityQueue()
PriorityQueue
, using a default initial capacity.Method Detail |
public final boolean isEmpty()
public final boolean hasMoreElements()
hasMoreElements
in interface java.util.Enumeration
public java.lang.Object nextElement()
nextElement
in interface java.util.Enumeration
public void addElement(java.lang.Object object)
object
- the element to addpublic final int capacity()
public final int size()
public int indexOf(java.lang.Object obj, int index)
obj
is null
, the search is for an element whose value is also null
; otherwise the object's equals
method is used to determine equality. Searching begins with the object specified by index, and precedes forwards.obj
- the object to search forindex
- the index to begin searching from (Default value
: 0)public final int indexOf(java.lang.Object obj)
indexOf(Object,int)
.public int lastIndexOf(java.lang.Object obj, int index)
obj
is null
, the search is for an element whose value is also null
; otherwise the object's equals
method is used to determine equality. Searching begins with the object specified by index, and precedes backwards.obj
- the object to search forindex
- the index to begin searching from (Default value
: tail, where tail is the index of the last element)public final int lastIndexOf(java.lang.Object obj)
lastIndexOf(Object,int)
.public java.lang.Object elementAt(int index)
index
- the index of the elementpublic final java.lang.Object firstElement()
NoSuchElementException
- if the queue is emptypublic java.lang.Object clone()
Object
s.clone
in class java.lang.Object
public final boolean contains(java.lang.Object obj)
obj
- the object to search fortrue
if the object is in this queue, false
otherwisepublic void insertElementAt(java.lang.Object obj, int index)
obj
- the object to insertpriority
- the prioritypublic void insertPrioritizedElement(java.lang.Object obj, int priority)
obj
- the object to insertpriority
- the prioritypublic final java.lang.Object lastElement()
NoSuchElementException
- if this queue is emptypublic final void removeAllElements()
public final void removeElementAt(int index)
index
- the indexpublic final boolean removeElement(java.lang.Object obj)
indexOf(Object)
method, and then deleting the match if one is found. If no match is found, the queue is unchanged.
Overrideable methods employed:
obj
- the objecttrue
if the object was found and removed, false
otherwisepublic final void setElementAt(java.lang.Object obj, int index)
obj
- the new objectindex
- the indexpublic final void setSize(int new_size)
new_size
- the new sizepublic final java.lang.String toString()
toString
method returned by each queued object, or "null" for elements that are null
, and p1, p2, ... are the objects' priorities.toString
in class java.lang.Object
public final void trimToSize()
public final void ensureCapacity(int capacity)
capacity
- the minimum capacity of this queuepublic void copyInto(java.lang.Object[] dest)
dest
- the destination arraypublic int priorityAt(int index)
Details: priorityAt returns the priority associated with the element at the specified index.
index
- the index
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |