Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.result
Class OrderingFromAssociation<T extends Comparable<T>,O extends DatabaseObject>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.result.OrderingFromAssociation<T,O>
Type Parameters:
T - data type of annotation.
O - database object type
All Implemented Interfaces:
OrderingResult, Result

public class OrderingFromAssociation<T extends Comparable<T>,O extends DatabaseObject>
extends Object
implements OrderingResult

Return an ordering result backed by a database. Note that the implementation will sort with O(n lg n) database accesses on average, O(n*n) in worst case to avoid having to store all objects in memory.

Author:
Erich Schubert

Nested Class Summary
protected  class OrderingFromAssociation.DerivedComparator
          Internally used comparator using a preexisting comparator for the given datatype
protected  class OrderingFromAssociation.ImpliedComparator
          Internally used comparator retrieving data from the database.
 
Field Summary
(package private)  int ascending
          Factor to signal ascending (+1) / descending (-1) order
protected  AssociationID<T> association
          AssocationID to use
protected  Comparator<T> comparator
          Internal comparator to use for sorting.
protected  Database<O> db
          Database
 
Constructor Summary
OrderingFromAssociation(Database<O> db, AssociationID<T> association)
          Minimal constructor, using implied comparator and ascending order.
OrderingFromAssociation(Database<O> db, AssociationID<T> association, boolean descending)
          Constructor without comparator
OrderingFromAssociation(Database<O> db, AssociationID<T> association, Comparator<T> comparator, boolean descending)
          Full Constructor (with comparator)
 
Method Summary
 Iterator<Integer> iter(Collection<Integer> ids)
          Sort the given collection of IDs and return an iterator for the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

db

protected Database<O extends DatabaseObject> db
Database


association

protected AssociationID<T extends Comparable<T>> association
AssocationID to use


comparator

protected Comparator<T extends Comparable<T>> comparator
Internal comparator to use for sorting.


ascending

int ascending
Factor to signal ascending (+1) / descending (-1) order

Constructor Detail

OrderingFromAssociation

public OrderingFromAssociation(Database<O> db,
                               AssociationID<T> association,
                               Comparator<T> comparator,
                               boolean descending)
Full Constructor (with comparator)

Parameters:
db - Database
association - AssociationID to use
comparator - Comparator for data type used by association
descending - boolean to mark descending ordering (true)

OrderingFromAssociation

public OrderingFromAssociation(Database<O> db,
                               AssociationID<T> association,
                               boolean descending)
Constructor without comparator

Parameters:
db - Database
association - AssociationID to use
descending - boolean to mark descending ordering (true)

OrderingFromAssociation

public OrderingFromAssociation(Database<O> db,
                               AssociationID<T> association)
Minimal constructor, using implied comparator and ascending order.

Parameters:
db - Database
association - AssociationID to use
Method Detail

iter

public Iterator<Integer> iter(Collection<Integer> ids)
Sort the given collection of IDs and return an iterator for the result.

Specified by:
iter in interface OrderingResult
Parameters:
ids - Collection of ids.
Returns:
iterator for sorted array of ids

Release 0.2.1 (2009-07-13_1605)