T
- the type of objects that the ranking function works withpublic class RankedSortedDistFunctionRerankingCollection<T extends AbstractObject> extends RankedSortedDistFunctionCollection<T>
RankedSortedDistFunctionCollection
that remembers
the original ordering of the objects and allows to re-rank the results
using another distance function.
This collection cannot be used during the operation evaluation, it is intended to be used ONLY when multiple re-ranking collections are computed on the same data.
Note that the original ordering can be used only by other instances of
RankedSortedDistFunctionRerankingCollection
and only when addAll(java.util.Collection)
method is called.
DEFAULT_INITIAL_CAPACITY, UNLIMITED_CAPACITY
Constructor and Description |
---|
RankedSortedDistFunctionRerankingCollection(DistanceFunction<? super T> rankingDistanceFunction,
T rankingObject,
float originalDistanceWeight,
int initialCapacity,
int maximalCapacity)
Constructs an empty collection with the specified initial and maximal capacity.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addAll(java.util.Collection<? extends RankedAbstractObject> c)
Add all of the elements in the specified collection to this list.
|
protected boolean |
addAllWithRanking(java.util.Collection<? extends RankedAbstractObject> c)
Compute the new ranking of the given data.
|
protected java.util.Collection<? extends RankedAbstractObject> |
getOriginalRankingCollection()
Returns the memorized collection with the original ranking.
|
void |
setMaximalCapacity(int capacity)
Set the maximal capacity of this collection.
|
add, add, add, create, getNewDistance, getOriginalDistanceWeight, getRankingDistanceFunction, getRankingObject, isRankingInAdd
add, clear, isEqual, isIgnoringDuplicates, rankObject, remove, remove, removeFirst, removeLast, setIgnoringDuplicates, toArray, toArray
getLastDistance, getThresholdDistance, iteratorDistanceRestricted, iteratorDistanceRestricted
addAllSortedArray, clone, 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 RankedSortedDistFunctionRerankingCollection(DistanceFunction<? super T> rankingDistanceFunction, T rankingObject, float originalDistanceWeight, int initialCapacity, int maximalCapacity) throws java.lang.IllegalArgumentException, java.lang.NullPointerException
rankInAddAll
should be set to false. If the collection is used as post-ranking,
the rankInAddAll
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 rankingrankingObject
- the object used for rankingoriginalDistanceWeight
- the weight of the original distance (if zero, the original distance is ignored)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 void setMaximalCapacity(int capacity)
SortedCollection
SortedCollection.size
.setMaximalCapacity
in class RankedSortedCollection
capacity
- the new collection maximal capacity (zero or negative value means unlimited capacity)public final boolean addAll(java.util.Collection<? extends RankedAbstractObject> c)
SortedCollection
SortedCollection
over the same type, then it is assumed that
it is ordered by the same comparator and these lists are effectively merged.addAll
in interface java.util.Collection<RankedAbstractObject>
addAll
in class SortedCollection<RankedAbstractObject>
c
- collection containing elements to be added to this listprotected final java.util.Collection<? extends RankedAbstractObject> getOriginalRankingCollection()
protected boolean addAllWithRanking(java.util.Collection<? extends RankedAbstractObject> c)
add
the data according to the new ranking.c
- the collection with the data to rank