| java.lang.Object jacareto.toolkit.PriorityList
PriorityList | public class PriorityList (Code) | | List for elements which have a priority.
If o1 and o2 are objects in the priority list with the priorities p(o1) and p(o2), the following
statement is true: p(o1) < p(o2) => index(o1) > index(02). Objects with the same
priority are ordered randomly.
If an object is added with no priority or a priority less than zero, then its priority is set to
-1 (which stands for the lowest priority).
author: Christian Spannagel version: 1.0 |
Inner Class :static class PriorityNode | |
Inner Class :public class PriorityIterator implements Iterator | |
Constructor Summary | |
public | PriorityList() Creates a new Priority List. |
Method Summary | |
public void | add(Object element, int priority) Add an element with a specified priority. | public void | add(Object element) Add an element with the lowest priority. | public boolean | contains(Object element) Returns whether an object is contained in the list or not. | public Object | get(int position) Returns an element at the specified position. | public int | getPriority(Object object) Returns the priority of a given object. | public Iterator | iterator() Returns an iterator on the list. | public void | remove(Object element) Removes an element. | public int | size() Returns the size of the list. |
PriorityList | public PriorityList()(Code) | | Creates a new Priority List.
|
add | public void add(Object element, int priority)(Code) | | Add an element with a specified priority.
Parameters: element - the element to add Parameters: priority - the priority |
add | public void add(Object element)(Code) | | Add an element with the lowest priority.
Parameters: element - the element to add |
contains | public boolean contains(Object element)(Code) | | Returns whether an object is contained in the list or not.
Parameters: element - the element to be tested true if the element is contained in the list, otherwisefalse |
get | public Object get(int position)(Code) | | Returns an element at the specified position.
Parameters: position - the position of the desired element the element |
getPriority | public int getPriority(Object object)(Code) | | Returns the priority of a given object.
Parameters: object - the object the priority, or -2 if the object is not contained. |
iterator | public Iterator iterator()(Code) | | Returns an iterator on the list. The element with the highest priority comes first.
the iterator |
remove | public void remove(Object element)(Code) | | Removes an element.
Parameters: element - the element to remove |
size | public int size()(Code) | | Returns the size of the list.
the size |
|
|