java.lang.Object
com.tomgibara.crinch.hashing.HashRange
Records the range of values that a hash value may take. Both range values are inclusive.
Field Summary
Modifier and TypeFieldDescriptionstatic final HashRangeFull int range from Integer.MIN_VALUE to Integer.MAX_VALUEstatic final HashRangeFull long range from Long.MIN_VALUE to Long.MAX_VALUEprivate static final BigIntegerLargest value that fits in an int.private static final BigIntegerSmallest value that fits in an int.private final booleanTrue if the bounds fit in an int.private BooleanCached flag if the size fits an int.private static final BigIntegerLargest value that fits in a long.private static final BigIntegerSmallest value that fits in a long.private final booleanTrue if the bounds fit in a long.private BooleanCached flag if the size fits a long.private final BigIntegerLargest value in the range, excluded.private final BigIntegerSmallest value in the range, included.static final HashRangePositive int range from 1 to Integer.MAX_VALUEstatic final HashRangePositive long range from 1 to Long.MAX_VALUEprivate BigIntegerCached count of values in the range.Constructor Summary
ConstructorsConstructorDescriptionHashRange(int minimum, int maximum) Construct a HashRange with int bounds.HashRange(long minimum, long maximum) Construct a HashRange with long bounds.HashRange(BigInteger minimum, BigInteger maximum) Construct a HashRange with BigInteger bounds.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanThe upper bound of this range, inclusive.The lower bound of this range, inclusive.getSize()The number of values this range spans, the maximum less the minimum plus one.inthashCode()booleanChecks whether both endpoints fit within the range of an int.booleanChecks whether the size of this range fits within an int.booleanChecks whether both endpoints fit within the range of a long.booleanChecks whether the size of this range fits within a long.booleanChecks whether this range starts at zero.toString()Creates an equivalent range whose minimum is zero.
Field Details
INT_MINIMUM
Smallest value that fits in an int.INT_MAXIMUM
Largest value that fits in an int.LONG_MINIMUM
Smallest value that fits in a long.LONG_MAXIMUM
Largest value that fits in a long.FULL_INT_RANGE
Full int range from Integer.MIN_VALUE to Integer.MAX_VALUEPOSITIVE_INT_RANGE
Positive int range from 1 to Integer.MAX_VALUEFULL_LONG_RANGE
Full long range from Long.MIN_VALUE to Long.MAX_VALUEPOSITIVE_LONG_RANGE
Positive long range from 1 to Long.MAX_VALUEminimum
Smallest value in the range, included.maximum
Largest value in the range, excluded.intBounded
private final boolean intBoundedTrue if the bounds fit in an int.longBounded
private final boolean longBoundedTrue if the bounds fit in a long.size
Cached count of values in the range.intSized
Cached flag if the size fits an int.longSized
Cached flag if the size fits a long.
Constructor Details
HashRange
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
getMaximum
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
Creates an equivalent range whose minimum is zero.- Returns:
- a zero-based version of this range
equals
hashCode
toString