eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class SortedLinkedList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.AbstractSequentialList
                    |
                    +--java.util.LinkedList
                          |
                          +--mss.ea.core.SortedLinkedList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class SortedLinkedList
extends java.util.LinkedList

Sorted linked list. This implementation of a linked list guarantees, that all contained elements are sorted. The elemntens must implement the interface Comparable or a Comparator must be given with the method setComparator().

Since:
0.1
Version:
0.1 (06-20-2001)
Author:
Andreas Rummler
See Also:
Serialized Form

Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SortedLinkedList()
           
SortedLinkedList(java.util.Collection c)
           
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object element)
           
 void add(java.lang.Object[] array)
          Inserts an array into the list.
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
 void addFirst(java.lang.Object o)
           
 void addLast(java.lang.Object o)
           
protected  int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two elements.
protected  int insert(java.lang.Object c)
          Inserts a new element.
 void removeRange(int fromIndex, int toIndex)
          Deletes a range in the list.
 java.lang.Object search(java.lang.Object o)
          Performs a binary search on the sorted list.
 java.lang.Object set(int index, java.lang.Object obj)
           
 void setComparator(java.util.Comparator c)
          Sets a new comparator.
 
Methods inherited from class java.util.LinkedList
clear, clone, contains, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, remove, remove, removeFirst, removeLast, 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
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

SortedLinkedList

public SortedLinkedList()

SortedLinkedList

public SortedLinkedList(java.util.Collection c)
Method Detail

add

public boolean add(java.lang.Object element)
Overrides:
add in class java.util.LinkedList

add

public void add(int index,
                java.lang.Object element)
Overrides:
add in class java.util.LinkedList

addAll

public boolean addAll(java.util.Collection c)
Overrides:
addAll in class java.util.LinkedList

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Overrides:
addAll in class java.util.LinkedList

addFirst

public void addFirst(java.lang.Object o)
Overrides:
addFirst in class java.util.LinkedList

addLast

public void addLast(java.lang.Object o)
Overrides:
addLast in class java.util.LinkedList

set

public java.lang.Object set(int index,
                            java.lang.Object obj)
Overrides:
set in class java.util.LinkedList

insert

protected int insert(java.lang.Object c)
Inserts a new element. This is the only possibility to insert a new element. This is necessary to guarantee that the elements are sorted. All overloaded methods use this method.
Parameters:
c - element to insert
Returns:
position the object was inserted at

search

public java.lang.Object search(java.lang.Object o)
Performs a binary search on the sorted list.
Parameters:
o - Object to search for using the set comparator
Returns:
the found object from the list or null instead

compare

protected int compare(java.lang.Object o1,
                      java.lang.Object o2)
Compares two elements. This is done using the given comparator. If that fails, both objects are casted to Comparable. A o1.compareTo( o2 ) is invoked afterwards.
Parameters:
o1 - first object
o2 - second object
Returns:
result of comparison

add

public void add(java.lang.Object[] array)
Inserts an array into the list.
Parameters:
array - array to insert into the list

removeRange

public void removeRange(int fromIndex,
                        int toIndex)
Deletes a range in the list. The range is between fromIndex (inclusive) to toIndex (exclusive). This is a wrapper for LinkedList.removeRange(), that is set to protected (who knows why ...).
Overrides:
removeRange in class java.util.AbstractList
Parameters:
fromIndex - lower index
toIndex - upper index

setComparator

public void setComparator(java.util.Comparator c)
Sets a new comparator.
Parameters:
c - new comparator

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS