T
- the type of objects that the ranking function works withpublic class RankedSortedDistFunctionMultiCollection<T extends AbstractObject> extends RankedSortedMultiCollection
RankedSortedMultiCollection
that uses a different distance
function to rank the objects. The additional collections store the objects ordered
by the respective sub-distance.
Note that this collection can be used either during the query evaluation or as after the computation is done (i.e. as a post-ranking of the collection).
For the first mode of operation (query evaluation - set by rankInAdd = false
),
the new distance is computed only when a query-object distance is computed via
add(messif.operations.AnswerType, messif.objects.AbstractObject, float, float[])
.
The already computed data added via add
or addAll
methods are not touched, so that the lists
can be merged without recomputing the data.
For the second mode of operation (post-ranking - set by rankInAdd = true
), the
objects have their ranking recomputed when added to this collection by any add
method. To create a separate re-ranked list, create a new instance of this collection
with rankInAdd = true
and add all
objects from the original collection.
RankedSortedMultiCollection.RankedSortedMultiCollectionComparator
DEFAULT_INITIAL_CAPACITY, UNLIMITED_CAPACITY
Constructor and Description |
---|
RankedSortedDistFunctionMultiCollection(DistanceFunctionMultiObject<? super T> rankingDistanceFunction,
AbstractObjectIterator<T> rankingObjects,
float originalDistanceWeight,
boolean rankInAdd,
int initialCapacity,
int maximalCapacity,
boolean dummyParam)
Constructs an empty collection with the specified initial and maximal capacity.
|
RankedSortedDistFunctionMultiCollection(DistanceFunctionMultiObject<? super T> rankingDistanceFunction,
T[] rankingObjects,
float originalDistanceWeight)
Constructs an empty collection.
|
RankedSortedDistFunctionMultiCollection(DistanceFunctionMultiObject<? super T> rankingDistanceFunction,
T[] rankingObjects,
float originalDistanceWeight,
boolean rankInAdd)
Constructs an empty collection.
|
RankedSortedDistFunctionMultiCollection(DistanceFunctionMultiObject<? super T> rankingDistanceFunction,
T[] rankingObjects,
float originalDistanceWeight,
boolean rankInAdd,
int initialCapacity,
int maximalCapacity)
Constructs an empty collection with the specified initial and maximal capacity.
|
Modifier and Type | Method and Description |
---|---|
RankedAbstractObject |
add(AnswerType answerType,
AbstractObject object,
float distance,
float[] objectDistances)
Add a distance-ranked object to this collection.
|
boolean |
add(RankedAbstractObject obj)
Adds the specified element to this list.
|
addAll, clear, clone, getCollection, getCollectionCount, getCollectionValueClass, getLastDistance, getSublistComparator, getSublistCount, getThresholdDistance, remove
add, isEqual, isIgnoringDuplicates, rankObject, remove, removeFirst, removeLast, setIgnoringDuplicates, setMaximalCapacity, toArray, toArray
getLastDistance, getThresholdDistance, iteratorDistanceRestricted, iteratorDistanceRestricted
addAllSortedArray, clone, compare, contains, containsAll, element, get, getComparator, getMaximalCapacity, isEmpty, isFull, iterator, iterator, offer, peek, poll, popLast, remove, removeAll, removeAll, removeFirstN, retainAll, size, toString
binarySearch, first, fullSearch, indexOf, last, mergeSort
public RankedSortedDistFunctionMultiCollection(DistanceFunctionMultiObject<? super T> rankingDistanceFunction, T[] rankingObjects, float originalDistanceWeight, boolean rankInAdd, int initialCapacity, int maximalCapacity) throws java.lang.IllegalArgumentException, java.lang.NullPointerException
rankInAdd
should be set to false. If the collection is used as post-ranking,
the rankInAdd
probably needs to be set to true, however
the correct type of objects must be present in the operation (i.e. the AnswerType
should be set to something above AnswerType.CLEARED_OBJECTS
.rankingDistanceFunction
- the distance function used for the rankingrankingObjects
- the objects used for rankingoriginalDistanceWeight
- the weight of the original distance (if zero, the original distance is ignored)rankInAdd
- flag whether the add
method computes the rank (true) or adds the ranked objects as-is (false)initialCapacity
- the initial capacity of the collectionmaximalCapacity
- the maximal capacity of the collectionjava.lang.IllegalArgumentException
- if the specified initial or maximal capacity is invalidjava.lang.NullPointerException
- if the ranking distance function is nullpublic RankedSortedDistFunctionMultiCollection(DistanceFunctionMultiObject<? super T> rankingDistanceFunction, AbstractObjectIterator<T> rankingObjects, float originalDistanceWeight, boolean rankInAdd, int initialCapacity, int maximalCapacity, boolean dummyParam) throws java.lang.IllegalArgumentException, java.lang.NullPointerException
rankInAdd
should be set to false. If the collection is used as post-ranking,
the rankInAdd
probably needs to be set to true, however
the correct type of objects must be present in the operation (i.e. the AnswerType
should be set to something above AnswerType.CLEARED_OBJECTS
.rankingDistanceFunction
- the distance function used for the rankingrankingObjects
- an iterator over the objects used for rankingoriginalDistanceWeight
- the weight of the original distance (if zero, the original distance is ignored)rankInAdd
- flag whether the add
method computes the rank (true) or adds the ranked objects as-is (false)initialCapacity
- the initial capacity of the collectionmaximalCapacity
- the maximal capacity of the collectionjava.lang.IllegalArgumentException
- if the specified initial or maximal capacity is invalidjava.lang.NullPointerException
- if the ranking distance function is nullpublic RankedSortedDistFunctionMultiCollection(DistanceFunctionMultiObject<? super T> rankingDistanceFunction, T[] rankingObjects, float originalDistanceWeight, boolean rankInAdd)
rankingDistanceFunction
- the distance function used for the rankingrankingObjects
- the object used for rankingoriginalDistanceWeight
- the weight of the original distance (if zero, the original distance is ignored)rankInAdd
- flag whether the add
method computes the rank (true) or adds the ranked objects as-is (false)public RankedSortedDistFunctionMultiCollection(DistanceFunctionMultiObject<? super T> rankingDistanceFunction, T[] rankingObjects, float originalDistanceWeight)
rankingDistanceFunction
- the distance function used for the rankingrankingObjects
- the object used for rankingoriginalDistanceWeight
- the weight of the original distance (if zero, the original distance is ignored)public RankedAbstractObject add(AnswerType answerType, AbstractObject object, float distance, float[] objectDistances) throws java.lang.IllegalArgumentException
RankedAbstractMetaObject
if the given objectDistances
array is not null.add
in class RankedSortedCollection
answerType
- the type of the objects added to this collectionobject
- the object to adddistance
- the distance of objectobjectDistances
- the array of distances to the respective sub-objects (can be null)java.lang.IllegalArgumentException
- if the answer type of this operation requires cloning but the passed object cannot be cloned or the distance function requires a different classpublic boolean add(RankedAbstractObject obj)
SortedCollection
add
in interface java.util.Collection<RankedAbstractObject>
add
in interface java.util.Queue<RankedAbstractObject>
add
in class RankedSortedMultiCollection
obj
- element to be appended to this list