nl.knowledgeplaza.util.collection
Class SortedList<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<T>
              extended by nl.knowledgeplaza.util.collection.SortedList<T>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess, SortedCollection<T>

public class SortedList<T>
extends ArrayList<T>
implements SortedCollection<T>

A sorted list based on ArrayList using binary search algorithmes. Force inserts (add and set with an index) are forbidden.

Version:
$Revision: 1.3 $
See Also:
Serialized Form

Field Summary
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SortedList(Comparator<T> comparator)
           
 
Method Summary
 boolean add(T o)
          insert in a sorted way, use binary search to determine where
 void add(T o, int idx)
          Throws an IllegalArgumentException
 boolean addAll(Collection<? extends T> c)
           
 Comparator<? super T> getComparator()
          Comparator
 int indexOf(Object o)
          Using binary search (contains need not be overridden since it uses indexOf)
 boolean remove(Object o)
          Using binary search (via indexOf)
 boolean removeAll(Collection<?> c)
          Using binary search (via remove)
 T set(int idx, T o)
          Throws an IllegalArgumentException
 void setComparator(Comparator<? super T> comparator)
           
 
Methods inherited from class java.util.ArrayList
add, addAll, clear, clone, contains, ensureCapacity, get, isEmpty, lastIndexOf, remove, removeRange, 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, 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, retainAll, subList
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

SortedList

public SortedList(Comparator<T> comparator)
Method Detail

getComparator

public Comparator<? super T> getComparator()
Comparator

Specified by:
getComparator in interface SortedCollection<T>

setComparator

public void setComparator(Comparator<? super T> comparator)
Specified by:
setComparator in interface SortedCollection<T>

add

public boolean add(T o)
insert in a sorted way, use binary search to determine where

Specified by:
add in interface Collection<T>
Specified by:
add in interface List<T>
Overrides:
add in class ArrayList<T>

add

public void add(T o,
                int idx)
Throws an IllegalArgumentException

Parameters:
o -
idx -

set

public T set(int idx,
             T o)
Throws an IllegalArgumentException

Specified by:
set in interface List<T>
Overrides:
set in class ArrayList<T>
Parameters:
idx -
o -

addAll

public boolean addAll(Collection<? extends T> c)
Specified by:
addAll in interface Collection<T>
Specified by:
addAll in interface List<T>
Overrides:
addAll in class ArrayList<T>

indexOf

public int indexOf(Object o)
Using binary search (contains need not be overridden since it uses indexOf)

Specified by:
indexOf in interface List<T>
Overrides:
indexOf in class ArrayList<T>

remove

public boolean remove(Object o)
Using binary search (via indexOf)

Specified by:
remove in interface Collection<T>
Specified by:
remove in interface List<T>
Overrides:
remove in class ArrayList<T>

removeAll

public boolean removeAll(Collection<?> c)
Using binary search (via remove)

Specified by:
removeAll in interface Collection<T>
Specified by:
removeAll in interface List<T>
Overrides:
removeAll in class AbstractCollection<T>


Copyright © 2012 KnowledgePlaza. All Rights Reserved.