de.uni_leipzig.bf.util
Class AlphaList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<java.lang.Comparable>
              extended by de.uni_leipzig.bf.util.AlphaList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.Comparable>, java.util.Collection<java.lang.Comparable>, java.util.List<java.lang.Comparable>, java.util.RandomAccess
Direct Known Subclasses:
ValuedAlphaList

public class AlphaList
extends java.util.ArrayList<java.lang.Comparable>

Implements an alphabetically sorted set. The retrieval of objects is binary and thus has a logarithmic worst case time complexity

Author:
Ngonga
See Also:
Serialized Form
 

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
AlphaList()
           
 
Method Summary
 boolean addd(java.lang.Comparable o)
          add elements in alphabetic order
 boolean containss(java.lang.Comparable o)
           
 int idxOf(java.lang.Comparable o)
          Implements a binary search to find objects in the list.
protected  boolean insert(int index, java.lang.Comparable o)
          Insert an element at a given position
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, 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, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

AlphaList

public AlphaList()
Method Detail

addd

public boolean addd(java.lang.Comparable o)
add elements in alphabetic order

Parameters:
o - The object to add
Returns:
true is everything went well

containss

public boolean containss(java.lang.Comparable o)

idxOf

public int idxOf(java.lang.Comparable o)
Implements a binary search to find objects in the list. Time complexity is thus logarithmic.

Parameters:
o - Object to look for
Returns:
-1 if the object is not in the list, else the index of the object

insert

protected boolean insert(int index,
                         java.lang.Comparable o)
Insert an element at a given position

Parameters:
index - Position where the object is to be added
o - Ojbect to add
Returns:
true when insertion was completed