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
FieldsModifier 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_VALUEstatic final HashRangePositive int range from 1 to Integer.MAX_VALUEstatic final HashRangePositive long range from 1 to Long.MAX_VALUEConstructor 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
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_VALUE
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