Package org.apache.wiki.util
Class PriorityList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.apache.wiki.util.PriorityList<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>
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
FieldsModifier and TypeFieldDescriptionstatic final intThis is the default priority, which is used if no priority is defined.Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Field Details
-
DEFAULT_PRIORITY
This is the default priority, which is used if no priority is defined. It's current value is zero.- See Also:
-
-
Constructor Details
-
PriorityList
public PriorityList()
-
-
Method Details
-
add
Adds an object to its correct place in the list, using the given priority.- Parameters:
o- Object to add.priority- Priority.
-
add
Adds an object using the default priority to the List.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classAbstractList<E>- Parameters:
o- Object to add.- Returns:
- true, as per the general Collections.add contract.
-
get
Returns the object at index "index". -
size
Returns the current size of the list.- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>- Returns:
- size of the list.
-