de.lmu.ifi.dbs.elki.utilities.datastructures.heap
Class KNNList<D extends Distance<D>>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<DistanceResultPair<D>>
              extended by de.lmu.ifi.dbs.elki.utilities.datastructures.heap.KNNList<D>
Type Parameters:
D -
All Implemented Interfaces:
Serializable, Cloneable, Iterable<DistanceResultPair<D>>, Collection<DistanceResultPair<D>>, List<DistanceResultPair<D>>, RandomAccess

public class KNNList<D extends Distance<D>>
extends ArrayList<DistanceResultPair<D>>

Finalized KNN List.

See Also:
Serialized Form

Nested Class Summary
protected static class KNNList.DBIDItr
          Proxy iterator for accessing DBIDs.
protected static class KNNList.DBIDView
          A view on the DBIDs of the result
protected static class KNNList.DistanceItr<D extends Distance<D>>
          Proxy iterator for accessing DBIDs.
protected static class KNNList.DistanceView<D extends Distance<D>>
          A view on the Distances of the result
 
Field Summary
private  int k
          The value of k this was materialized for.
private  D maxdist
          The maximum distance to return if size() < k
private static long serialVersionUID
          Serial ID
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
protected KNNList(KNNHeap<D> heap, D maxdist)
          Constructor, to be called from KNNHeap only!
 
Method Summary
 boolean add(DistanceResultPair<D> e)
           
 void add(int index, DistanceResultPair<D> element)
           
 boolean addAll(Collection<? extends DistanceResultPair<D>> c)
           
 boolean addAll(int index, Collection<? extends DistanceResultPair<D>> c)
           
 ArrayDBIDs asDBIDs()
          View as ArrayDBIDs
static ArrayDBIDs asDBIDs(List<? extends DistanceResultPair<?>> list)
          View as ArrayDBIDs
 List<D> asDistanceList()
          View as list of distances
static
<D extends Distance<D>>
List<D>
asDistanceList(List<? extends DistanceResultPair<D>> list)
          View as list of distances
 void clear()
           
 int getK()
          Get the K parameter.
 D getKNNDistance()
          Get the distance to the k nearest neighbor, or maxdist otherwise.
 D getMaximumDistance()
          Get maximum distance in list
 DistanceResultPair<D> remove(int index)
           
 boolean remove(Object o)
           
 DistanceResultPair<D> set(int index, DistanceResultPair<D> element)
           
 void trimToSize()
           
 
Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, removeRange, size, toArray, toArray
 
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
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial ID

See Also:
Constant Field Values

k

private final int k
The value of k this was materialized for.


maxdist

private final D extends Distance<D> maxdist
The maximum distance to return if size() < k

Constructor Detail

KNNList

protected KNNList(KNNHeap<D> heap,
                  D maxdist)
Constructor, to be called from KNNHeap only!

Parameters:
heap - Calling heap.
maxdist - infinite distance to return.
Method Detail

getK

public int getK()
Get the K parameter.

Returns:
K

getKNNDistance

public D getKNNDistance()
Get the distance to the k nearest neighbor, or maxdist otherwise.

Returns:
Maximum distance

getMaximumDistance

public D getMaximumDistance()
Get maximum distance in list


asDBIDs

public ArrayDBIDs asDBIDs()
View as ArrayDBIDs

Returns:
Static DBIDs

asDistanceList

public List<D> asDistanceList()
View as list of distances

Returns:
List of distances view

add

public boolean add(DistanceResultPair<D> e)
Specified by:
add in interface Collection<DistanceResultPair<D extends Distance<D>>>
Specified by:
add in interface List<DistanceResultPair<D extends Distance<D>>>
Overrides:
add in class ArrayList<DistanceResultPair<D extends Distance<D>>>

add

public void add(int index,
                DistanceResultPair<D> element)
Specified by:
add in interface List<DistanceResultPair<D extends Distance<D>>>
Overrides:
add in class ArrayList<DistanceResultPair<D extends Distance<D>>>

addAll

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

addAll

public boolean addAll(int index,
                      Collection<? extends DistanceResultPair<D>> c)
Specified by:
addAll in interface List<DistanceResultPair<D extends Distance<D>>>
Overrides:
addAll in class ArrayList<DistanceResultPair<D extends Distance<D>>>

clear

public void clear()
Specified by:
clear in interface Collection<DistanceResultPair<D extends Distance<D>>>
Specified by:
clear in interface List<DistanceResultPair<D extends Distance<D>>>
Overrides:
clear in class ArrayList<DistanceResultPair<D extends Distance<D>>>

remove

public DistanceResultPair<D> remove(int index)
Specified by:
remove in interface List<DistanceResultPair<D extends Distance<D>>>
Overrides:
remove in class ArrayList<DistanceResultPair<D extends Distance<D>>>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<DistanceResultPair<D extends Distance<D>>>
Specified by:
remove in interface List<DistanceResultPair<D extends Distance<D>>>
Overrides:
remove in class ArrayList<DistanceResultPair<D extends Distance<D>>>

set

public DistanceResultPair<D> set(int index,
                                 DistanceResultPair<D> element)
Specified by:
set in interface List<DistanceResultPair<D extends Distance<D>>>
Overrides:
set in class ArrayList<DistanceResultPair<D extends Distance<D>>>

trimToSize

public void trimToSize()
Overrides:
trimToSize in class ArrayList<DistanceResultPair<D extends Distance<D>>>

asDBIDs

public static ArrayDBIDs asDBIDs(List<? extends DistanceResultPair<?>> list)
View as ArrayDBIDs

Returns:
Static DBIDs

asDistanceList

public static <D extends Distance<D>> List<D> asDistanceList(List<? extends DistanceResultPair<D>> list)
View as list of distances

Returns:
List of distances view

Release 0.4.0 (2011-09-20_1324)