messif.objects.util
Class RankedSortedCollection

java.lang.Object
  extended by messif.utility.SortedArrayData<T,T>
      extended by messif.utility.SortedCollection<RankedAbstractObject>
          extended by messif.objects.util.RankedSortedCollection
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<RankedAbstractObject>, java.util.Collection<RankedAbstractObject>
Direct Known Subclasses:
DoubleSortedCollection

public class RankedSortedCollection
extends SortedCollection<RankedAbstractObject>

Specialization of SortedCollection that is specific for distance-ranked objects.

See Also:
Serialized Form

Constructor Summary
RankedSortedCollection()
          Constructs an empty collection.
RankedSortedCollection(int initialCapacity, int maximalCapacity)
          Constructs an empty collection with the specified initial and maximal capacity.
RankedSortedCollection(int initialCapacity, int maximalCapacity, java.util.Comparator<? super RankedAbstractObject> comparator)
          Constructs an empty collection with the specified initial and maximal capacity.
RankedSortedCollection(LocalAbstractObject referenceObject, java.util.Iterator<? extends LocalAbstractObject> iterator)
          Creates a new collection filled with objects provided by the iterator.
RankedSortedCollection(LocalAbstractObject referenceObject, ObjectProvider<? extends LocalAbstractObject> objectProvider)
          Creates a new collection filled with objects provided by the objectProvider.
 
Method Summary
 float getLastDistance()
          Returns the distance of the last object in this collection.
 float getThresholdDistance()
          Returns the threshold distance for this collection.
 
Methods inherited from class messif.utility.SortedCollection
add, addAll, clear, clone, compare, contains, containsAll, get, getMaximalCapacity, isEmpty, isFull, iterator, iterator, popLast, remove, remove, removeAll, removeFirst, removeLast, retainAll, size, toArray, toArray, toString
 
Methods inherited from class messif.utility.SortedArrayData
binarySearch, first, fullSearch, indexOf, last, mergeSort
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

RankedSortedCollection

public RankedSortedCollection(int initialCapacity,
                              int maximalCapacity,
                              java.util.Comparator<? super RankedAbstractObject> comparator)
                       throws java.lang.IllegalArgumentException
Constructs an empty collection with the specified initial and maximal capacity.

Parameters:
initialCapacity - the initial capacity of the collection
maximalCapacity - the maximal capatity of the collection
comparator - the comparator that defines ordering
Throws:
java.lang.IllegalArgumentException - if the specified initial or maximal capacity is invalid

RankedSortedCollection

public RankedSortedCollection(int initialCapacity,
                              int maximalCapacity)
                       throws java.lang.IllegalArgumentException
Constructs an empty collection with the specified initial and maximal capacity. The order is defined using the natural order of items.

Parameters:
initialCapacity - the initial capacity of the collection
maximalCapacity - the maximal capatity of the collection
Throws:
java.lang.IllegalArgumentException - if the specified initial or maximal capacity is invalid

RankedSortedCollection

public RankedSortedCollection()
                       throws java.lang.IllegalArgumentException
Constructs an empty collection. The order is defined using the natural order of items. The initial capacity of the collection is set to 16 and maximal capacity is not limited.

Throws:
java.lang.IllegalArgumentException - if the specified initial or maximal capacity is invalid

RankedSortedCollection

public RankedSortedCollection(LocalAbstractObject referenceObject,
                              java.util.Iterator<? extends LocalAbstractObject> iterator)
Creates a new collection filled with objects provided by the iterator. Objects are ranked by the distance measured from the given referenceObject.

Parameters:
referenceObject - the reference object from which the distance is measured
iterator - the iterator on objects to add to the collection

RankedSortedCollection

public RankedSortedCollection(LocalAbstractObject referenceObject,
                              ObjectProvider<? extends LocalAbstractObject> objectProvider)
Creates a new collection filled with objects provided by the objectProvider. Objects are ranked by the distance measured from the given referenceObject.

Parameters:
referenceObject - the reference object from which the distance is measured
objectProvider - the provider of objects to add to the collection
Method Detail

getLastDistance

public float getLastDistance()
                      throws java.util.NoSuchElementException
Returns the distance of the last object in this collection.

Returns:
the distance of the last object in this collection
Throws:
java.util.NoSuchElementException - if this collection is empty

getThresholdDistance

public float getThresholdDistance()
Returns the threshold distance for this collection. If this collection has not reached the maximal size (specified in constructor) yet, LocalAbstractObject.MAX_DISTANCE is returned. Otherwise, the distance of the last object of this collection is returned.

Returns:
the distance to the last object in this collection or LocalAbstractObject.MAX_DISTANCE if there are not enough objects.