net.obsearch
Class AbstractOBPriorityQueue<O extends AbstractOBResult<?>>

java.lang.Object
  extended by net.obsearch.AbstractOBPriorityQueue<O>
Type Parameters:
O - Result object to be used by the queue
All Implemented Interfaces:
Iterable<O>
Direct Known Subclasses:
OBPriorityQueueByte, OBPriorityQueueDouble, OBPriorityQueueFloat, OBPriorityQueueInt, OBPriorityQueueInvertedByte, OBPriorityQueueInvertedDouble, OBPriorityQueueInvertedFloat, OBPriorityQueueInvertedInt, OBPriorityQueueInvertedLong, OBPriorityQueueInvertedShort, OBPriorityQueueLong, OBPriorityQueueShort

public abstract class AbstractOBPriorityQueue<O extends AbstractOBResult<?>>
extends Object
implements Iterable<O>

This class stores matching results. It is used to minimize the amount of distance computations required. To optimize a bit, the same priority queue is used to store results for the user

Since:
0.7
Author:
Arnoldo Jose Muller Molina

Field Summary
protected  int k
          Maximum number of elements to be used.
protected  PriorityQueue<O> queue
          The internal queue used to store results.
 
Constructor Summary
AbstractOBPriorityQueue()
          Creates a priority queue of k = 3.
AbstractOBPriorityQueue(int k)
          Creates a priority queue by setting the maximum number of elements to be accepted.
 
Method Summary
 boolean equals(Object obj)
          Same "sort" of objects means that the distances of the included objects are the same, and the repetitions of such distances are the same.
 int getK()
           
 int getSize()
           
 List<O> getSortedElements()
           
 boolean isFull()
          Returns true if the queue is full.
 Iterator<O> iterator()
          Returns an interator with all the elements in no particular order.
 O peek()
           
 O poll()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

queue

protected PriorityQueue<O extends AbstractOBResult<?>> queue
The internal queue used to store results.


k

protected int k
Maximum number of elements to be used. Note that this value is byte. Many elements would make OBSearch very slow.

Constructor Detail

AbstractOBPriorityQueue

public AbstractOBPriorityQueue()
Creates a priority queue of k = 3.


AbstractOBPriorityQueue

public AbstractOBPriorityQueue(int k)
Creates a priority queue by setting the maximum number of elements to be accepted.

Parameters:
k - maximum number of elements to accept
Method Detail

iterator

public final Iterator<O> iterator()
Returns an interator with all the elements in no particular order.

Specified by:
iterator in interface Iterable<O extends AbstractOBResult<?>>
Returns:
Iterator with all the value

getSize

public final int getSize()
Returns:
The size of the elements of this queue.

peek

public O peek()

getK

public final int getK()
Returns:
The k of the given queue.

poll

public O poll()

isFull

public boolean isFull()
Returns true if the queue is full.

Returns:

equals

public final boolean equals(Object obj)
Same "sort" of objects means that the distances of the included objects are the same, and the repetitions of such distances are the same.

Overrides:
equals in class Object
Parameters:
obj - The AbstractOBPriorityQueue that will be compared.
Returns:
True if the given AbstractOBPriorityQueue contains the same "sort" of objects.

getSortedElements

public List<O> getSortedElements()
Returns:
the sorted list from smaller to larger of elements.

toString

public final String toString()
Overrides:
toString in class Object
Returns:
A string representation of the queue for debugging purposes.


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