com.ecyrd.jspwiki.util
Class PriorityList
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList
com.ecyrd.jspwiki.util.PriorityList
- All Implemented Interfaces:
- Iterable, Collection, List
public class PriorityList
- extends AbstractList
Builds a simple, priority-based List implementation. The list
will be sorted according to the priority. If two items are
inserted with the same priority, their order is the insertion order - i.e. the new one
is appended last in the insertion list.
Priority is an integer, and the list is sorted in descending order
(that is, 100 is before 10 is before 0 is before -40).
Field Summary |
static int |
DEFAULT_PRIORITY
This is the default priority, which is used if no priority
is defined. |
Method Summary |
boolean |
add(Object o)
Adds an object using the default priority to the List. |
void |
add(Object o,
int priority)
Adds an object to its correct place in the list, using the
given priority. |
Object |
get(int index)
Returns the object at index "index". |
int |
size()
Returns the current size of the list. |
Methods inherited from class java.util.AbstractList |
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList |
DEFAULT_PRIORITY
public static final int DEFAULT_PRIORITY
- This is the default priority, which is used if no priority
is defined. It's current value is zero.
- See Also:
- Constant Field Values
PriorityList
public PriorityList()
add
public void add(Object o,
int priority)
- Adds an object to its correct place in the list, using the
given priority.
- Parameters:
o
- Object to add.priority
- Priority.
add
public boolean add(Object o)
- Adds an object using the default priority to the List.
- Specified by:
add
in interface Collection
- Specified by:
add
in interface List
- Overrides:
add
in class AbstractList
- Parameters:
o
- Object to add.
- Returns:
- true, as per the general Collections.add contract.
get
public Object get(int index)
- Returns the object at index "index".
- Specified by:
get
in interface List
- Specified by:
get
in class AbstractList
- Parameters:
index
- The index.
- Returns:
- The object at the list at the position "index".
size
public int size()
- Returns the current size of the list.
- Specified by:
size
in interface Collection
- Specified by:
size
in interface List
- Specified by:
size
in class AbstractCollection
- Returns:
- size of the list.