net.obsearch.result
Class OBResultInvertedInt<O>

java.lang.Object
  extended by net.obsearch.AbstractOBResult<O>
      extended by net.obsearch.result.OBResultInvertedInt<O>
All Implemented Interfaces:
Comparable

public final class OBResultInvertedInt<O>
extends AbstractOBResult<O>

This class is used to store a single match result. A single result consists of the object found, the distance of this object with the query and an internal id. Inverted results will put first smaller values in the priority queue.

Since:
0.7
Author:
Arnoldo Jose Muller Molina

Field Summary
protected  int distance
          Distance of the object found and the query.
 
Fields inherited from class net.obsearch.AbstractOBResult
id, object
 
Constructor Summary
OBResultInvertedInt()
          Default constructor.
OBResultInvertedInt(O object, long id, int distance)
          Create a new OBResultInt.
 
Method Summary
 int compareTo(Object o)
          We implement the interface comparable so we provide this method.
 int getDistance()
           
 void setDistance(int x)
          Sets the distance to a new value x.
 String toString()
          Return a human readable representation of the object.
 
Methods inherited from class net.obsearch.AbstractOBResult
getId, getObject, setId, setObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

distance

protected int distance
Distance of the object found and the query.

Constructor Detail

OBResultInvertedInt

public OBResultInvertedInt()
Default constructor. Used mostly to minimize the amount of object creations.


OBResultInvertedInt

public OBResultInvertedInt(O object,
                           long id,
                           int distance)
Create a new OBResultInt.

Parameters:
object - the result found.
id - The internal id of the result.
distance - Distance of the result and the original query.
Method Detail

getDistance

public final int getDistance()
Returns:
The distance of the result and the original query.

setDistance

public final void setDistance(int x)
Sets the distance to a new value x.

Parameters:
x - The new value to set.

compareTo

public int compareTo(Object o)
We implement the interface comparable so we provide this method. The only difference is that we return bigger objects first. (The comparable contract is multiplied by -1)

Parameters:
o - The object that will be compared.
Returns:
1 if this object is smaller than o 0 if this object is equal than o -1 if this object is greater than o

toString

public String toString()
Return a human readable representation of the object.

Overrides:
toString in class Object
Returns:
a human readable representation of the object.


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