net.obsearch.index.ghs
Class SketchPriorityQueue

java.lang.Object
  extended by net.obsearch.index.ghs.SketchPriorityQueue
All Implemented Interfaces:
Iterable<SketchProjection>

public final class SketchPriorityQueue
extends Object
implements Iterable<SketchProjection>

This data structure simulates a priority queue of objects sorted by their distance to some other object. It assumes several things for performance reasons: 1)Distances are discrete. 2) Objects to be stored are longs 3) The maximum distance value is a value m that is very small (64 for example :)). This priority queue uses a lot of memory if queueSize is too large.

Author:
Arnoldo Jose Muller Molina

Constructor Summary
SketchPriorityQueue(int maxDistance, int queueSize)
          Creates the queue
 
Method Summary
 void add(SketchProjection object)
          Add an object that is at a certain distance.
 int currentMaxDistance()
           
 CBitVector[] get()
          Return the closeXBst long objects We do not include the original distances to reduce the creation of objects.
 ArrayList<SketchProjection> getResults()
           
 Iterator<SketchProjection> iterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SketchPriorityQueue

public SketchPriorityQueue(int maxDistance,
                           int queueSize)
Creates the queue

Parameters:
maxDistance - maximum distance that will be inserted in the queue. (from 0 to maxDistance)
queueSize - size of the queue (number of closest elements to be obtained).
Method Detail

currentMaxDistance

public int currentMaxDistance()
Returns:
The max distance

add

public void add(SketchProjection object)
Add an object that is at a certain distance.

Parameters:
object - the object to add
distance - the distance of the object.

get

public CBitVector[] get()
Return the closeXBst long objects We do not include the original distances to reduce the creation of objects.

Returns:
the closest long objects

getResults

public ArrayList<SketchProjection> getResults()

iterator

public Iterator<SketchProjection> iterator()
Specified by:
iterator in interface Iterable<SketchProjection>


Copyright © 2007-2011 Arnoldo Jose Muller Molina. All Rights Reserved.