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 Details

    • entryComparator

      public static Comparator<it.unimi.dsi.fastutil.objects.Object2ObjectMap.Entry<Label,​LazyWeight>> entryComparator
      A natural comparator for Entry<Label>. It orders considering the alphabetical order of Label.
    • lazyWeightLabelSeparator

      public static final String lazyWeightLabelSeparator
      See Also:
      Constant Field Values
  • Constructor Details

    • LabeledLazyWeightTreeMap

      public LabeledLazyWeightTreeMap()
      Necessary constructor for the factory. The internal structure is built and empty.
    • LabeledLazyWeightTreeMap

      public LabeledLazyWeightTreeMap​(LabeledLazyWeightTreeMap lvm)
      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

      public static LabeledLazyWeightTreeMap createLabeledLazyTreeMap()
    • createLabeledLazyTreeMap

      public static LabeledLazyWeightTreeMap createLabeledLazyTreeMap​(LabeledLazyWeightTreeMap lim)
    • entryAsString

      public static final String entryAsString​(Label label, LazyWeight value)
      Parameters:
      value -
      label -
      Returns:
      string representing the labeled value, i.e., "(value, label)"
    • parse

      public static LabeledLazyWeightTreeMap parse​(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:
       \{[\(<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 - a String object.
      Returns:
      a LabeledValueTreeMap object if inputMap represents a valid map, null otherwise.
    • alreadyRepresents

      public boolean alreadyRepresents​(Label newLabel, LazyWeight newLW)
      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 use entrySet() instead of keySet() and, then, get(Label). With 1000 or more items, it is better to use keySet() 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

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
      Returns:
      true if they contain the same set of values.
    • get

      public LazyWeight get​(Label l)
    • getInt

      public double getInt​(Label l)
    • getMaxValue

      public double getMaxValue()
    • getMinValue

      public double getMinValue()
    • getMinValueSubsumedBy

      public double getMinValueSubsumedBy​(Label l)
    • getMinValueConsistentWith

      public double getMinValueConsistentWith​(Label l)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • keySet

      public it.unimi.dsi.fastutil.objects.ObjectSet<Label> 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

      public boolean put​(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!
      Parameters:
      newLabel -
      newLW -
      Returns:
      true if the LW has been inserted.
    • putForcibly

      public double putForcibly​(Label l, LazyWeight lw)
      Parameters:
      l -
      lw -
      Returns:
      previous value if present, Constants.INT_NULL otherwise;
    • remove

      public double remove​(Label l)
    • size

      public int size()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • values

      public it.unimi.dsi.fastutil.doubles.DoubleSet values()
    • main

      public static void main​(String[] args)