nl.knowledgeplaza.util.collection
Class SortedList

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

public class SortedList
extends java.util.ArrayList
implements SortedCollection

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

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

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

See Also:
Constant Field Values
Constructor Detail

SortedList

public SortedList(java.util.Comparator comparator)
Method Detail

getComparator

public java.util.Comparator getComparator()
Comparator

Specified by:
getComparator in interface SortedCollection

setComparator

public void setComparator(java.util.Comparator comparator)
Specified by:
setComparator in interface SortedCollection

add

public boolean add(java.lang.Object o)
insert in a sorted way, use binary search to determine where

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.ArrayList

add

public void add(java.lang.Object o,
                int idx)
Throws an IllegalArgumentException

Parameters:
o -
idx -

set

public java.lang.Object set(int idx,
                            java.lang.Object o)
Throws an IllegalArgumentException

Specified by:
set in interface java.util.List
Overrides:
set in class java.util.ArrayList
Parameters:
idx -
o -

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.ArrayList

indexOf

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

Specified by:
indexOf in interface java.util.List
Overrides:
indexOf in class java.util.ArrayList

remove

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

Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.ArrayList

removeAll

public boolean removeAll(java.util.Collection c)
Using binary search (via remove)

Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.List
Overrides:
removeAll in class java.util.AbstractCollection


Copyright © 2010 KnowledgePlaza. All Rights Reserved.