java.lang.Object
com.tomgibara.crinch.hashing.HashRange

public class HashRangeextends Object
Records the range of values that a hash value may take. Both range values are inclusive.
  • Field Details

    • FULL_INT_RANGE

      public static final HashRange FULL_INT_RANGE
      Full int range from Integer.MIN_VALUE to Integer.MAX_VALUE
    • POSITIVE_INT_RANGE

      public static final HashRange POSITIVE_INT_RANGE
      Positive int range from 1 to Integer.MAX_VALUE
    • FULL_LONG_RANGE

      public static final HashRange FULL_LONG_RANGE
      Full long range from Long.MIN_VALUE to Long.MAX_VALUE
    • POSITIVE_LONG_RANGE

      public static final HashRange POSITIVE_LONG_RANGE
      Positive long range from 1 to Long.MAX_VALUE
  • Constructor Details

    • HashRange

      public HashRange(BigInteger minimum, BigInteger maximum)
      Construct a HashRange with BigInteger bounds.
      Parameters:
      minimum - the minimum value (inclusive)
      maximum - the maximum value (inclusive)
    • HashRange

      public HashRange(int minimum, int maximum)
      Construct a HashRange with int bounds.
      Parameters:
      minimum - the minimum value (inclusive)
      maximum - the maximum value (inclusive)
    • HashRange

      public HashRange(long minimum, long maximum)
      Construct a HashRange with long bounds.
      Parameters:
      minimum - the minimum value (inclusive)
      maximum - the maximum value (inclusive)
  • Method Details

    • isZeroBased

      public boolean isZeroBased()
      Checks whether this range starts at zero.
      Returns:
      true if the minimum value is zero
    • isIntBounded

      public boolean isIntBounded()
      Checks whether both endpoints fit within the range of an int.
      Returns:
      true if the range fits within int bounds
    • isLongBounded

      public boolean isLongBounded()
      Checks whether both endpoints fit within the range of a long.
      Returns:
      true if the range fits within long bounds
    • getMinimum

      public BigInteger getMinimum()
      The lower bound of this range, inclusive.
      Returns:
      the minimum value
    • getMaximum

      public BigInteger getMaximum()
      The upper bound of this range, inclusive.
      Returns:
      the maximum value
    • getSize

      public BigInteger getSize()
      The number of values this range spans, the maximum less the minimum plus one.
      Returns:
      the size of the range
    • isIntSized

      public boolean isIntSized()
      Checks whether the size of this range fits within an int.
      Returns:
      true if the size fits within int range
    • isLongSized

      public boolean isLongSized()
      Checks whether the size of this range fits within a long.
      Returns:
      true if the size fits within long range
    • zeroBased

      public HashRange zeroBased()
      Creates an equivalent range whose minimum is zero.
      Returns:
      a zero-based version of this range
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object