org.xshare.base.collections
Class SortedCollection

java.lang.Object
  |
  +--org.xshare.base.collections.SortedCollection
All Implemented Interfaces:
java.util.Collection

public class SortedCollection
extends java.lang.Object
implements java.util.Collection

Version:
$Revision: 1.5 $
Author:
Oliver Fischer
See Also:
http://developer.java.sun.com/developer/bugParade/bugs/4151747.html

Constructor Summary
SortedCollection()
          Constructs a new sorted collection of elements.
SortedCollection(java.util.Collection pMaster)
           
SortedCollection(java.util.Collection pMaster, java.util.Comparator pSorter)
           
SortedCollection(java.util.Comparator pSorter)
           
SortedCollection(java.util.Iterator pSource)
           
SortedCollection(java.util.Iterator pSource, java.util.Comparator pSorter)
           
 
Method Summary
 boolean add(java.lang.Object pNewObj)
           
 boolean addAll(java.util.Collection c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
          Checks if a given Object is contained by this SortedCollection.
 boolean containsAll(java.util.Collection c)
           
protected  org.xshare.base.collections.LinkedNode findFirstGreater(java.lang.Object pCompareObj)
           
protected  org.xshare.base.collections.LinkedNode internalContains(java.lang.Object pToLookUp)
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
          Returns a Iterator over all elements in this collection starting from the first element.
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 boolean retainAll(java.util.Collection c)
           
 int size()
           
 java.lang.Object[] toArray()
          Returns a array containing all objects of this collection.
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

SortedCollection

public SortedCollection()
Constructs a new sorted collection of elements. All elements added to this collection will be sorted according to their "natural" order. Hence they elements must implement the Comparable iterface.


SortedCollection

public SortedCollection(java.util.Iterator pSource,
                        java.util.Comparator pSorter)
Throws:
java.lang.NullPointerException - if one of both parameters is null.

SortedCollection

public SortedCollection(java.util.Iterator pSource)
Throws:
java.lang.NullPointerException - if the given Iterator is null.
java.lang.ClassCastException - if the elements provided by the given Iterator don't implement Comparable

SortedCollection

public SortedCollection(java.util.Comparator pSorter)
Throws:
java.lang.NullPointerException - if the given Comparator is null.

SortedCollection

public SortedCollection(java.util.Collection pMaster,
                        java.util.Comparator pSorter)
Throws:
java.lang.NullPointerException - if one of both parameters is null.

SortedCollection

public SortedCollection(java.util.Collection pMaster)
Throws:
java.lang.ClassCastException - if the objects contained in the given Collection don't implement the Comparable interface
java.lang.NullPointerException - if the given Collection is null.
Method Detail

clear

public void clear()
Specified by:
clear in interface java.util.Collection

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection
Throws:
java.lang.IllegalArgumentException - if one does't implement Comparable and this collection doesn't have a custom Comparator.

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection
See Also:
contains(Object)

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection

add

public boolean add(java.lang.Object pNewObj)
Specified by:
add in interface java.util.Collection
Throws:
java.lang.IllegalArgumentException - if the element does't implement Comparable and this collection doesn't have a custom Comparator.

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.Collection

toArray

public java.lang.Object[] toArray()
Returns a array containing all objects of this collection. The implementation guarantees that the returned array contains all elements contained in this collection and the the array has the same order as the collection itself.

Specified by:
toArray in interface java.util.Collection
Returns:
a Object[] containing all elements of this collection.

iterator

public java.util.Iterator iterator()
Returns a Iterator over all elements in this collection starting from the first element. The returned iterator works on the underlying collection directly.

Specified by:
iterator in interface java.util.Collection
Returns:
a Iterator over all elements in the collection with support for Iterator.remove()

contains

public boolean contains(java.lang.Object o)
Checks if a given Object is contained by this SortedCollection.

Specified by:
contains in interface java.util.Collection
Returns:
a boolean value which is true if at least one Object is containted by this list. This is true is one object fills in the condition ObjectFromList.equals(givenObject). Otherwise this method returns false.

internalContains

protected org.xshare.base.collections.LinkedNode internalContains(java.lang.Object pToLookUp)

findFirstGreater

protected org.xshare.base.collections.LinkedNode findFirstGreater(java.lang.Object pCompareObj)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection

size

public int size()
Specified by:
size in interface java.util.Collection


jKiska Base 0.10 [http://jkiska.sourceforge.net]