Package it.univr.di.labeledvalue.lazy
Class LabeledLazyWeightTreeMap
java.lang.Object
it.univr.di.labeledvalue.lazy.LabeledLazyWeightTreeMap
public class LabeledLazyWeightTreeMap extends Object
Simple implementation of
LabeledLazyWeightTreeMap interface using LazyWieght instead of int.- Version:
- $Id: $Id
- Author:
- Roberto Posenato
- See Also:
LabeledLazyWeightTreeMap
-
Field Summary
Fields Modifier and Type Field Description static Comparator<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,LazyWeight>>entryComparatorA natural comparator for Entry<Label>.static StringlazyWeightLabelSeparator -
Constructor Summary
Constructors Constructor Description LabeledLazyWeightTreeMap()Necessary constructor for the factory.LabeledLazyWeightTreeMap(LabeledLazyWeightTreeMap lvm)Constructor to clone the structure. -
Method Summary
Modifier and Type Method Description booleanalreadyRepresents(Label newLabel, LazyWeight newLW)voidclear()static LabeledLazyWeightTreeMapcreateLabeledLazyTreeMap()static LabeledLazyWeightTreeMapcreateLabeledLazyTreeMap(LabeledLazyWeightTreeMap lim)static StringentryAsString(Label label, LazyWeight value)it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,LazyWeight>>entrySet()Up to 1000 items in the map it is better to useentrySet()instead ofkeySet()and, then,get(Label).it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,LazyWeight>>entrySet(it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,LazyWeight>> setToReuse)booleanequals(Object o)LazyWeightget(Label l)doublegetInt(Label l)doublegetMaxValue()doublegetMinValue()doublegetMinValueConsistentWith(Label l)doublegetMinValueSubsumedBy(Label l)inthashCode()it.unimi.dsi.fastutil.objects.ObjectSet<Label>keySet()it.unimi.dsi.fastutil.objects.ObjectSet<Label>keySet(it.unimi.dsi.fastutil.objects.ObjectSet<Label> setToReuse)static voidmain(String[] args)static LabeledLazyWeightTreeMapparse(String inputMap)Parse a string representing a LabeledLazyWeightTreeMap and return an object containing the labeled values represented by the string.
The format of the string is:booleanput(Label newLabel, LazyWeight newLW)Adds the pair 〈l,i〉.
Moreover, tries to eliminate all labels that are redundant.
IMPORTANT!
This version of the method is very redundant but simple to check!doubleputForcibly(Label l, LazyWeight lw)doubleremove(Label l)intsize()StringtoString()it.unimi.dsi.fastutil.doubles.DoubleSetvalues()
-
Field Details
-
entryComparator
public static Comparator<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,LazyWeight>> entryComparatorA natural comparator for Entry<Label>. It orders considering the alphabetical order of Label. -
lazyWeightLabelSeparator
- See Also:
- Constant Field Values
-
-
Constructor Details
-
LabeledLazyWeightTreeMap
public LabeledLazyWeightTreeMap()Necessary constructor for the factory. The internal structure is built and empty. -
LabeledLazyWeightTreeMap
Constructor to clone the structure. For optimization issue, this method clone only LabeledIntTreeMap object.- Parameters:
lvm- the LabeledValueTreeMap to clone. If lvm is null, this will be a empty map.
-
-
Method Details
-
createLabeledLazyTreeMap
-
createLabeledLazyTreeMap
-
entryAsString
- Parameters:
value-label-- Returns:
- string representing the labeled value, i.e., "(value, label)"
-
parse
Parse a string representing a LabeledLazyWeightTreeMap and return an object containing the labeled values represented by the string.
The format of the string is:\{[\(<lazyWeight>, <key>\) ]*\}where a lazyWeight can be an integer or a linear function (multiplier factor and constant, both integer, separated by a space), i.e.,<integer> | <multiplier constant>
- Parameters:
inputMap- aStringobject.- Returns:
- a LabeledValueTreeMap object if
inputMaprepresents a valid map, null otherwise.
-
alreadyRepresents
- Parameters:
newLabel-newLW-- Returns:
- true if the current map can represent the value. In positive case, an addition of the element does not change the map. If returns false, then an addition of the value to the map would modify the map.
-
clear
public void clear() -
entrySet
public it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,LazyWeight>> entrySet()Up to 1000 items in the map it is better to useentrySet()instead ofkeySet()and, then,get(Label). With 1000 or more items, it is better to usekeySet()approach.- Returns:
- a set view of all elements.
-
entrySet
public it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,LazyWeight>> entrySet(it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,LazyWeight>> setToReuse) -
equals
-
get
-
getInt
-
getMaxValue
public double getMaxValue() -
getMinValue
public double getMinValue() -
getMinValueSubsumedBy
-
getMinValueConsistentWith
-
hashCode
public int hashCode() -
keySet
- Returns:
- a set view of all labels present into this map.
-
keySet
public it.unimi.dsi.fastutil.objects.ObjectSet<Label> keySet(it.unimi.dsi.fastutil.objects.ObjectSet<Label> setToReuse)- Parameters:
setToReuse-- Returns:
- a set view of all labels present into this map.
-
put
Adds the pair 〈l,i〉.
Moreover, tries to eliminate all labels that are redundant.
IMPORTANT!
This version of the method is very redundant but simple to check!- Parameters:
newLabel-newLW-- Returns:
- true if the LW has been inserted.
-
putForcibly
- Parameters:
l-lw-- Returns:
- previous value if present, Constants.INT_NULL otherwise;
-
remove
-
size
public int size() -
toString
-
values
public it.unimi.dsi.fastutil.doubles.DoubleSet values() -
main
-