public class PrecomputedDistancesFixedArrayFilter extends PrecomputedDistancesFilter
Modifier and Type | Field and Description |
---|---|
protected int |
actualSize
The actual size of precompDist (if it was pre-buffered)
|
protected float[] |
precompDist
The list of precomputed distances
|
Modifier | Constructor and Description |
---|---|
|
PrecomputedDistancesFixedArrayFilter()
Creates a new instance of PrecomputedDistancesFixedArrayFilter.
|
protected |
PrecomputedDistancesFixedArrayFilter(BinaryInput input,
BinarySerializator serializator)
Creates a new instance of PrecomputedDistancesFixedArrayFilter loaded from binary input.
|
|
PrecomputedDistancesFixedArrayFilter(int initialSize)
Creates a new instance of PrecomputedDistancesFixedArrayFilter.
|
|
PrecomputedDistancesFixedArrayFilter(LocalAbstractObject object)
Creates a new instance of PrecomputedDistancesFixedArrayFilter.
|
|
PrecomputedDistancesFixedArrayFilter(LocalAbstractObject object,
int initialSize)
Creates a new instance of PrecomputedDistancesFixedArrayFilter
|
|
PrecomputedDistancesFixedArrayFilter(java.lang.String distancesString)
Creates a new instance of PrecomputedDistancesFixedArrayFilter from a string.
|
Modifier and Type | Method and Description |
---|---|
int |
addPrecompDist(AbstractObjectList<LocalAbstractObject> pivots,
LocalAbstractObject obj)
Add distances at the end of internal list of precomputed distances.
|
int |
addPrecompDist(float dist)
Add distance at the end of internal list of precomputed distances.
|
int |
addPrecompDist(float[] dists)
Add the passed distances at the end of internal list of precomputed distances.
|
int |
addPrecompDist(LocalAbstractObject[] pivots,
LocalAbstractObject obj)
Add distances at the end of internal list of precomputed distances.
|
float |
addPrecompDist(LocalAbstractObject p,
LocalAbstractObject o)
Add distance at the end of internal list of precomputed distances.
|
protected boolean |
addPrecomputedDistance(LocalAbstractObject obj,
float distance,
float[] metaDistances)
Adds a precomputed distance to this filter.
|
int |
binarySerialize(BinaryOutput output,
BinarySerializator serializator)
Binary-serialize this object into the
output . |
java.lang.Object |
clone()
Creates and returns a copy of this object.
|
boolean |
excludeUsingPrecompDist(PrecomputedDistancesFilter targetFilter,
float radius)
Returns true if object associated with targetFilter filter can be excluded (filtered out) using this precomputed distances.
|
boolean |
excludeUsingPrecompDist(PrecomputedDistancesFixedArrayFilter targetFilter,
float radius)
Return true if the obj has been filtered out using stored precomputed distance.
|
int |
getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.
|
float[] |
getPrecompDist()
Return the whole array of precomputed distances.
|
float |
getPrecompDist(int position)
Returns the precomputed distance at the specified index.
|
int |
getPrecompDistSize()
Returns the number of stored precomputed distance.
|
float |
getPrecomputedDistance(LocalAbstractObject obj,
float[] metaDistances)
Returns a precomputed distance to the given object and the respective meta distances
array.
|
boolean |
includeUsingPrecompDist(PrecomputedDistancesFilter targetFilter,
float radius)
Returns true if object associated with targetFilter filter can be included using this precomputed distances.
|
boolean |
includeUsingPrecompDist(PrecomputedDistancesFixedArrayFilter targetFilter,
float radius)
Returns true if object associated with targetFilter filter can be included using this precomputed distances.
|
void |
insertPrecompDist(int pos,
float dist)
Insert distance into internal list of precomputed distances at the specified position.
|
float |
insertPrecompDist(int pos,
LocalAbstractObject p,
LocalAbstractObject o)
Insert distance into internal list of precomputed distances at the specified position.
|
protected boolean |
isDataWritable()
Returns whether this filter's data can be written to a text stream.
|
void |
removeLastPrecompDists(int cnt)
Removes the requested number of distances from the end of the array.
|
void |
removePrecompDist(int pos)
Remove distance at the specified index from the internal list of precomputed distances.
|
void |
resetAllPrecompDist()
Removes all precomputed distances and sets the actual array size to zero (the maximal size stays).
|
protected void |
resizePrecompDistArray(int newSize)
Resize the internal precomputed distances array to the newSize.
|
void |
setFixedPivotsPrecompDist(float[] precompDist)
Replaces the current array of precomputed distances with the values passed in the argument.
|
void |
setPrecompDist(int pos,
float dist)
Set distance in the internal list of precomputed distances at the specified position.
|
float |
setPrecompDist(int pos,
LocalAbstractObject p,
LocalAbstractObject o)
Set distance at the end of internal list of precomputed distances.
|
protected void |
writeData(java.io.OutputStream stream)
Store this filter's data to a text stream.
|
getPrecomputedDistance, write
protected float[] precompDist
protected int actualSize
public PrecomputedDistancesFixedArrayFilter()
public PrecomputedDistancesFixedArrayFilter(LocalAbstractObject object)
object
- the object to which to add this filterpublic PrecomputedDistancesFixedArrayFilter(int initialSize)
initialSize
- the initial size for this filter's internal array of distancespublic PrecomputedDistancesFixedArrayFilter(LocalAbstractObject object, int initialSize)
object
- the object to which to add this filterinitialSize
- the initial size for this filter's internal array of distancespublic PrecomputedDistancesFixedArrayFilter(java.lang.String distancesString) throws java.lang.IllegalArgumentException
distancesString
- string to create the filter fromjava.lang.IllegalArgumentException
- if the string is of inappropriate formatprotected PrecomputedDistancesFixedArrayFilter(BinaryInput input, BinarySerializator serializator) throws java.io.IOException
input
- the input to read the PrecomputedDistancesFixedArrayFilter fromserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error reading from the inputprotected boolean isDataWritable()
PrecomputedDistancesFilter
PrecomputedDistancesFilter.writeData(java.io.OutputStream)
should
provide a valid writing implementation.isDataWritable
in class PrecomputedDistancesFilter
protected void writeData(java.io.OutputStream stream) throws java.io.IOException
PrecomputedDistancesFilter
writeData
in class PrecomputedDistancesFilter
stream
- the stream to store this object tojava.io.IOException
- if there was an error while writing to streamprotected boolean addPrecomputedDistance(LocalAbstractObject obj, float distance, float[] metaDistances)
PrecomputedDistancesFilter
addPrecomputedDistance
in class PrecomputedDistancesFilter
obj
- the object the distance to which is addeddistance
- the distance to addmetaDistances
- the array that is filled with the distances of the respective encapsulated objects
(it is null if the object does not have meta distances)public int addPrecompDist(float dist)
dist
- distance to appendpublic int addPrecompDist(float[] dists)
dists
- array of distances to appendpublic float addPrecompDist(LocalAbstractObject p, LocalAbstractObject o)
p
- first object (usually pivot)o
- second objectLocalAbstractObject.UNKNOWN_DISTANCE
is returned if any of objects passed is null.public int addPrecompDist(AbstractObjectList<LocalAbstractObject> pivots, LocalAbstractObject obj)
o
.
If pivots
or o
is null, no change is done.pivots
- list of objects (usually pivots)obj
- second objectpublic int addPrecompDist(LocalAbstractObject[] pivots, LocalAbstractObject obj)
o
.
If pivots
or o
is null, no change is done.pivots
- list of objects (usually pivots)obj
- second objectpublic void insertPrecompDist(int pos, float dist) throws java.lang.IndexOutOfBoundsException
pos
- the index to insert the distance atdist
- the distance to insertjava.lang.IndexOutOfBoundsException
- is thrown when pos
is out of bounds.public float insertPrecompDist(int pos, LocalAbstractObject p, LocalAbstractObject o) throws java.lang.IndexOutOfBoundsException
pos
- the index to insert the distance atp
- first object (usually pivot)o
- second objectLocalAbstractObject.UNKNOWN_DISTANCE
is returned if any of objects passed is null.java.lang.IndexOutOfBoundsException
- is thrown when pos
is out of bounds.public void setPrecompDist(int pos, float dist) throws java.lang.IndexOutOfBoundsException
pos
- the index to set the distance atdist
- the distance to setjava.lang.IndexOutOfBoundsException
- is thrown when pos
is out of bounds.public float setPrecompDist(int pos, LocalAbstractObject p, LocalAbstractObject o) throws java.lang.IndexOutOfBoundsException
pos
- the index to insert the distance atp
- first object (usually pivot)o
- second objectLocalAbstractObject.UNKNOWN_DISTANCE
is returned if any of objects passed is null.java.lang.IndexOutOfBoundsException
- is thrown when pos
is out of bounds.public void removePrecompDist(int pos) throws java.lang.IndexOutOfBoundsException
pos
- the index to remove the distance atjava.lang.IndexOutOfBoundsException
- is thrown when pos
is out of bounds.public void removeLastPrecompDists(int cnt) throws java.lang.IndexOutOfBoundsException
cnt
- the number of distances to removejava.lang.IndexOutOfBoundsException
- is thrown when the list of precomputed distance is already empty.public void setFixedPivotsPrecompDist(float[] precompDist)
precompDist
- an array of new distancespublic int getPrecompDistSize()
public void resetAllPrecompDist()
public float getPrecompDist(int position)
position
the function returns LocalAbstractObject.UNKNOWN_DISTANCE
.position
- the index to retrieve the distance frompublic float[] getPrecompDist()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class PrecomputedDistancesFilter
java.lang.CloneNotSupportedException
- if this object cannot be cloned.public final boolean excludeUsingPrecompDist(PrecomputedDistancesFilter targetFilter, float radius)
PrecomputedDistancesFilter
LocalAbstractObject.excludeUsingPrecompDist(messif.objects.LocalAbstractObject, float)
for full explanation.excludeUsingPrecompDist
in class PrecomputedDistancesFilter
targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic boolean excludeUsingPrecompDist(PrecomputedDistancesFixedArrayFilter targetFilter, float radius)
targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic final boolean includeUsingPrecompDist(PrecomputedDistancesFilter targetFilter, float radius)
PrecomputedDistancesFilter
LocalAbstractObject.includeUsingPrecompDist(messif.objects.LocalAbstractObject, float)
for full explanation.includeUsingPrecompDist
in class PrecomputedDistancesFilter
targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic boolean includeUsingPrecompDist(PrecomputedDistancesFixedArrayFilter targetFilter, float radius)
LocalAbstractObject.includeUsingPrecompDist(messif.objects.LocalAbstractObject, float)
for full explanation.targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic float getPrecomputedDistance(LocalAbstractObject obj, float[] metaDistances)
PrecomputedDistancesFilter
obj
,
an UNKNOWN_DISTANCE
is returned.
The metaDistances
are filled only if the array is not null
and this distance filter has the respective precomputed meta distances stored.getPrecomputedDistance
in class PrecomputedDistancesFilter
obj
- the object for which the precomputed distance is returnedmetaDistances
- the array that is filled with the distances of the respective encapsulated objects, if it is not nullprotected void resizePrecompDistArray(int newSize)
newSize
- the new size for the precomputed arraypublic int binarySerialize(BinaryOutput output, BinarySerializator serializator) throws java.io.IOException
output
.binarySerialize
in interface BinarySerializable
binarySerialize
in class PrecomputedDistancesFilter
output
- the output that this object is binary-serialized intoserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error during serializationpublic int getBinarySize(BinarySerializator serializator)
getBinarySize
in interface BinarySerializable
getBinarySize
in class PrecomputedDistancesFilter
serializator
- the serializator used to write objects