Class WeightedSelectorImmutable<T>
java.lang.Object
org.aksw.commons.collections.selector.WeightedSelectorImmutable<T>
- Type Parameters:
T-
- All Implemented Interfaces:
Cloneable,WeightedSelector<T>
Immutable selector over an immutable collection of (item, weight) pairs.
Weights are internally treated as doubles, however, any subclass of Number may be used in the pair itself.
Access complexity is O(Log(n))
Similar to EnumeratedDistribution from commons math
- Author:
- Claus Stadler, Oct 12, 2018
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleprotected NavigableMap<Double,Map.Entry<T, ? extends Number>> -
Constructor Summary
ConstructorsConstructorDescriptionWeightedSelectorImmutable(NavigableMap<Double, Map.Entry<T, ? extends Number>> offsetToEntry, double nextOffset) -
Method Summary
Modifier and TypeMethodDescriptionclone()Cloning mechanism to allow simple implementation of backtracking.static <X,T> WeightedSelectorImmutable<T> static <T> WeightedSelectorImmutable<T>static <X,T> WeightedSelectorImmutable<T> create(Iterable<X> items, Function<? super X, ? extends T> getEntity, Function<? super X, ? extends Number> getWeight) static <T> WeightedSelectorImmutable<T>Collection<Map.Entry<T,? extends Number>> entries()Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aksw.commons.collections.selector.WeightedSelector
entryMap, isEmpty, sample
-
Field Details
-
offsetToEntry
-
nextOffset
protected double nextOffset
-
-
Constructor Details
-
Method Details
-
clone
Description copied from interface:WeightedSelectorCloning mechanism to allow simple implementation of backtracking.- Specified by:
clonein interfaceWeightedSelector<T>- Overrides:
clonein classObject- Returns:
-
sampleEntry
- Specified by:
sampleEntryin interfaceWeightedSelector<T>
-
create
public static <X,T> WeightedSelectorImmutable<T> create(Iterable<? extends Map.Entry<T, ? extends Number>> entries) -
create
-
create
public static <T> WeightedSelectorImmutable<T> create(Iterable<T> items, Function<? super T, ? extends Number> getWeight) -
create
public static <X,T> WeightedSelectorImmutable<T> create(Iterable<X> items, Function<? super X, ? extends T> getEntity, Function<? super X, ? extends Number> getWeight) -
entries
- Specified by:
entriesin interfaceWeightedSelector<T>
-