Class DynamicLinearProbeNonNegativeIntCounter

java.lang.Object
ai.timefold.solver.core.impl.util.DynamicLinearProbeNonNegativeIntCounter

@NullMarked public final class DynamicLinearProbeNonNegativeIntCounter extends Object
A class representing a non-negative int-to-int map that is compacted so the backing int arrays are as small as possible.

IMPORTANT: As the class does a linear probe, it is only appropriate to use when counting up to a few dozen keys. When using more keys, use a Map instead.

  • Constructor Details

    • DynamicLinearProbeNonNegativeIntCounter

      public DynamicLinearProbeNonNegativeIntCounter()
  • Method Details

    • getCount

      public int getCount(int key)
      Get the count of key, or 0 if it not present in the counter.
    • increment

      public void increment(int key)
      Increment the count of key, creating an entry for it if none is present.
    • decrement

      public void decrement(int key)
      Decrement the count of key, deleting the entry for it if count is 0.
    • toString

      public String toString()
      Overrides:
      toString in class Object