Jadex 0.96-beta1

jadex.util.collection
Class SortedList

java.lang.Object
  extended by java.util.AbstractCollection
      extended by java.util.AbstractList
          extended by java.util.AbstractSequentialList
              extended by java.util.LinkedList
                  extended by jadex.util.collection.SortedList
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, Queue

public class SortedList
extends LinkedList

A sorted list allowing duplicates of elements (unlike java.util.TreeSet). The list is kept sorted, while elements are being added.

See Also:
Serialized Form

Constructor Summary
SortedList()
          Constructs an empty list with ascending order.
SortedList(boolean ascending)
          Constructs an empty list with given order.
SortedList(Comparator comp, boolean ascending)
          Constructs an empty list with given order.
 
Method Summary
 void add(int index, Object element)
          Inserts the specified element at the specified position in this list.
 boolean add(Object o)
          Appends the specified element to the end of this list.
 boolean addAll(Collection c)
          Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.
 boolean addAll(int index, Collection c)
          Inserts all of the elements in the specified collection into this list, starting at the specified position.
 void addFirst(Object o)
          Inserts the given element at the beginning of this list.
 void addLast(Object o)
          Appends the given element to the end of this list.
 int insertElement(int index, Object obj)
          Insert an element into the list.
 
Methods inherited from class java.util.LinkedList
clear, clone, contains, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, peek, poll, remove, remove, remove, removeFirst, removeLast, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

SortedList

public SortedList()
Constructs an empty list with ascending order.


SortedList

public SortedList(boolean ascending)
Constructs an empty list with given order.

Parameters:
ascending - True, if the list shoudl sort ascending.

SortedList

public SortedList(Comparator comp,
                  boolean ascending)
Constructs an empty list with given order.

Parameters:
comp - A comparator to use for comparing elements.
ascending - True, if the list shoudl sort ascending.
Method Detail

addFirst

public void addFirst(Object o)
Inserts the given element at the beginning of this list.

Overrides:
addFirst in class LinkedList
Parameters:
o - the element to be inserted at the beginning of this list.

addLast

public void addLast(Object o)
Appends the given element to the end of this list. (Identical in function to the add method; included only for consistency.)

Overrides:
addLast in class LinkedList
Parameters:
o - the element to be inserted at the end of this list.

add

public boolean add(Object o)
Appends the specified element to the end of this list.

Specified by:
add in interface Collection
Specified by:
add in interface List
Overrides:
add in class LinkedList
Parameters:
o - element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

addAll

public boolean addAll(Collection c)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this list, and this list is nonempty.)

Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
Overrides:
addAll in class LinkedList
Parameters:
c - the elements to be inserted into this list.
Returns:
true if this list changed as a result of the call.
Throws:
NullPointerException - if the specified collection is null.

addAll

public boolean addAll(int index,
                      Collection c)
Inserts all of the elements in the specified collection into this list, starting at the specified position.

Specified by:
addAll in interface List
Overrides:
addAll in class LinkedList
Parameters:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this list.
Returns:
true if this list changed as a result of the call.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).
NullPointerException - if the specified collection is null.

add

public void add(int index,
                Object element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
add in interface List
Overrides:
add in class LinkedList
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

insertElement

public int insertElement(int index,
                         Object obj)
Insert an element into the list.

Parameters:
index - The index where to start insertion.
obj - The element to insert.
Returns:
The index where the element was actually inserted.

Jadex 0.96-beta1

Submit a bug or feature
For further API reference and developer documentation, see the Jadex User Guide and the Jadex Tutorial. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, and working code examples.

Copyright (C) 2002-2007 Lars Braubach, Alexander Pokahr - University of Hamburg. Use is subject to license terms.