Class LabeledIntSimpleMap

java.lang.Object
it.univr.di.labeledvalue.AbstractLabeledIntMap
it.univr.di.labeledvalue.LabeledIntSimpleMap
All Implemented Interfaces:
LabeledIntMap, Serializable
Direct Known Subclasses:
LabeledIntSimpleMap.LabeledIntNotMinMapView

public class LabeledIntSimpleMap extends AbstractLabeledIntMap
Simple implementation of LabeledIntMap interface without minimization. This class is provided only to give an evidence that without minimization of labeled value sets, any CSTN algorithm can be very slowly.
Version:
$Rev: 851 $
Author:
Roberto Posenato
See Also:
  • Field Details

    • mainMap

      it.unimi.dsi.fastutil.objects.Object2IntMap<Label> mainMap
      Map of label
    • updateCount

      it.unimi.dsi.fastutil.objects.Object2IntMap<Label> updateCount
      Counter of labeled value updates.
  • Constructor Details

    • LabeledIntSimpleMap

      public LabeledIntSimpleMap(LabeledIntMap 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 an empty map.
    • LabeledIntSimpleMap

      public LabeledIntSimpleMap(LabeledIntMap lvm, boolean optimize)
      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 an empty map.
      optimize - true for having the label shortest as possible, false otherwise. For example, the set {(0, ¬C), (1, C)} is represented as {(0, ⊡), (1, C)} if this parameter is true.
    • LabeledIntSimpleMap

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

      public LabeledIntSimpleMap(boolean optimize)
      Necessary constructor for the factory. The internal structure is built and empty.
      Parameters:
      optimize - true for having the label shortest as possible, false otherwise. For example, the set {(0, ¬C), (1, C)} is represented as {(0, ⊡), (1, C)} if this parameter is true.
  • Method Details

    • alreadyRepresents

      public boolean alreadyRepresents(@Nonnull Label newLabel, int newValue)
      Parameters:
      newLabel - a Label object.
      newValue - the new value.
      Returns:
      true if the (newValue, newLabel) is already represented in the map.
    • clear

      public void clear()
      Description copied from interface: LabeledIntMap
      Remove all entries of the map.
      See Also:
    • entrySet

      public it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<Label>> entrySet()
      This method returns a copy of the view of the map. Any modification of the map IS NOT propagated to the return set.
      In other word, it is possible to iterate on this map for modifying the original map without worried to lose any element.
      Returns:
      The set of all entries of the map.
      See Also:
    • entrySet

      public it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<Label>> entrySet(@NotNull @NotNull it.unimi.dsi.fastutil.objects.ObjectSet<it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<Label>> setToReuse)
      This method returns a copy of the view of the map. Any modification of the map IS NOT propagated to the return set.
      In other word, it is possible to iterate on this map for modifying the original map without worried to lose any element.
      Parameters:
      setToReuse - a ObjectSet object.
      Returns:
      The set of all entries of the map.
      See Also:
      • Map.entrySet()
      • a containter for the returned set. It will be clear before filling with the entries.
      • Object2IntMap.Entry
    • get

      public int get(Label l)
      Parameters:
      l - an Label object.
      Returns:
      the value associated to l if it exists, Constants.INT_NULL otherwise.
    • keySet

      public it.unimi.dsi.fastutil.objects.ObjectSet<Label> keySet()
      Description copied from interface: LabeledIntMap
      A copy of all labels in the map. The set must not be connected with the map.
      Returns:
      a copy of all labels in the map.
    • keySet

      public it.unimi.dsi.fastutil.objects.ObjectSet<Label> keySet(it.unimi.dsi.fastutil.objects.ObjectSet<Label> setToReuse)
      Parameters:
      setToReuse - a set to be reused for filling with the copy of labels
      Returns:
      a copy of all labels in the map. The set must not be connected with the map.
    • newInstance

      public LabeledIntSimpleMap newInstance()
      Description copied from interface: LabeledIntMap
      Factory
      Returns:
      an object of type LabeledIntMap.
    • newInstance

      public LabeledIntMap newInstance(boolean optimize)
      Factory
      Parameters:
      optimize - true for having the label shortest as possible, false otherwise. For example, the set {(0, ¬C), (1, C)} is represented as {(0, ⊡), (1, C)} if this parameter is true.
      Returns:
      an object of type LabeledIntMap.
    • newInstance

      public LabeledIntSimpleMap newInstance(LabeledIntMap lim)
      Description copied from interface: LabeledIntMap
      Factory
      Parameters:
      lim - an object to clone.
      Returns:
      an object of type LabeledIntMap.
    • newInstance

      public LabeledIntMap newInstance(LabeledIntMap lim, boolean optimize)
      Factory
      Parameters:
      lim - an object to clone.
      optimize - true for having the label shortest as possible, false otherwise. For example, the set {(0, ¬C), (1, C)} is represented as {(0, ⊡), (1, C)} if this parameter is true.
      Returns:
      an object of type LabeledIntMap.
    • put

      public boolean put(Label newLabel, int newValue)
      Description copied from interface: LabeledIntMap
      Put a label with value i if label l is not null and there is not a labeled value in the set with label l or it is present but with a value higher than l.

      Not mandatory: the method can remove or modify other labeled values of the set in order to minimize the labeled values present guaranteeing that no info is lost.

      Parameters:
      newLabel - a not null label.
      newValue - a not Constants.INT_NULL value.
      Returns:
      true if (l,i) has been inserted. Since an insertion can remove more than one redundant labeled values, it is nonsensical to return "the old value" as expected from a classical put method.
    • putForcibly

      public void putForcibly(Label l, int i)
      Put the labeled value without any control. It is dangerous, but it can help in some cases.
      Parameters:
      l - a Label object.
      i - the new value.
    • remove

      public int remove(Label l)
      Description copied from interface: LabeledIntMap
      Remove the label l from the map. If the l is not present, it does nothing.
      Parameters:
      l - a not null label.
      Returns:
      the previous value associated with l, or Constants.INT_NULL if there was no mapping for l.
      See Also:
    • size

      public int size()
      Specified by:
      size in interface LabeledIntMap
      Overrides:
      size in class AbstractLabeledIntMap
      Returns:
      the number of labeled value (value with empty label included).
      See Also:
    • unmodifiable

      public LabeledIntMap.LabeledIntMapView unmodifiable()
      Returns:
      a read-only view of this.
    • values

      public it.unimi.dsi.fastutil.ints.IntSet values()
      Returns:
      the set of all integer present in the map as an ordered list.