// SPDX-FileCopyrightText: 2020 Roberto Posenato // // SPDX-License-Identifier: LGPL-3.0-or-later package it.univr.di.labeledvalue; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import it.unimi.dsi.fastutil.ints.IntArraySet; import it.unimi.dsi.fastutil.ints.IntSet; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry; import it.unimi.dsi.fastutil.objects.ObjectArraySet; import it.unimi.dsi.fastutil.objects.ObjectSet; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.Serial; import java.io.Serializable; import java.util.logging.Logger; /** * Simple implementation of {@link it.univr.di.labeledvalue.LabeledIntMap} interface. *

* When creating an object, it is possible to specify if the labeled values represented in the map should be maintained as the minimal equivalent ones. * * @author Roberto Posenato * @version $Rev$ * @see LabeledIntMap */ //@SuppressFBWarnings(value = "HE_HASHCODE_NO_EQUALS", justification = "Equal is not necessary for this complementary class.") public class LabeledIntHierarchyMap extends AbstractLabeledIntMap { /** * Simple class to represent a labeled value in the hierarchy. * * @author posenato */ @SuppressWarnings({"CompareToUsesNonFinalVariable", "NonFinalFieldReferenceInEquals", "NonFinalFieldReferencedInHashCode"}) static class HierarchyNode implements Object2IntMap.Entry

* Design choice: the set of labeled values of this map is organized as a double-linked hierarchy of labeled values. A labeled value * (label, value) is the father of another labeled value (label1, value1) if label1 subsumes label and value1 < value. */ HierarchyNode root; /** * Just for debugging */ private String putHistory = ""; /** * Constructor to clone the structure. * * @param lvm the LabeledValueTreeMap to clone. If LVM is null, this will be an empty map. */ LabeledIntHierarchyMap(final LabeledIntMap lvm) { this(); if (lvm == null) { return; } for (final Entry