Class NonZeroCachingCounter

java.lang.Object
edu.berkeley.cs.jqf.fuzz.util.Counter
edu.berkeley.cs.jqf.fuzz.util.NonZeroCachingCounter

public class NonZeroCachingCounter extends Counter
An extension of Counter that caches which entries are non-zero.

This version of counter is used by classes such as Coverage, which require frequent queries of the non-zero locations.

  • Constructor Details

    • NonZeroCachingCounter

      public NonZeroCachingCounter(int size)
  • Method Details

    • clear

      public void clear()
      Description copied from class: Counter
      Clears the counter by setting all values to zero.
      Overrides:
      clear in class Counter
    • incrementAtIndex

      public int incrementAtIndex(int index, int delta)
      Overrides:
      incrementAtIndex in class Counter
    • getNonZeroSize

      public int getNonZeroSize()
      Description copied from class: Counter
      Returns the number of indices with non-zero counts.
      Overrides:
      getNonZeroSize in class Counter
      Returns:
      the number of indices with non-zero counts
    • hasNonZeros

      public boolean hasNonZeros()
      Description copied from class: Counter
      Checks if all indices have zero counts and returns a boolean as result.
      Overrides:
      hasNonZeros in class Counter
      Returns:
      true if some indices have non-zero counts, otherwise false.
    • getNonZeroIndices

      public org.eclipse.collections.api.list.primitive.IntList getNonZeroIndices()
      Description copied from class: Counter
      Returns a set of indices at which the count is non-zero.

      Note that indices are different from keys, in that multiple keys can map to the same index due to hash collisions.

      Overrides:
      getNonZeroIndices in class Counter
      Returns:
      a set of indices at which the count is non-zero
    • getNonZeroValues

      public org.eclipse.collections.api.list.primitive.IntList getNonZeroValues()
      Description copied from class: Counter
      Returns a set of non-zero count values in this counter.
      Overrides:
      getNonZeroValues in class Counter
      Returns:
      a set of non-zero count values in this counter.
    • setAtIndex

      public void setAtIndex(int index, int newValue)
      Overrides:
      setAtIndex in class Counter