Package net.algart.arrays
Class DataFile.Range
java.lang.Object
net.algart.arrays.DataFile.Range
- All Implemented Interfaces:
Comparable<DataFile.Range>
- Enclosing interface:
DataFile
Pair of 2 long values position
and length, describing the range position..position+length-1
of linear addresses in some data file
.
This class is immutable and thread-safe.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns -1 if the starting position of this range is less than the starting position of the argument, 1 if it is greater and 0 if they are equal.boolean
Indicates whether some other range is equal to this one, i.e. it contains the same starting position and length.int
hashCode()
Returns the hash code for this range.long
length()
Returns the range length.long
position()
Returns the starting range position.toString()
Returns a brief string description of this factory.static DataFile.Range
valueOf
(long position, long length) Creates new range position..position+length-1.
-
Method Details
-
valueOf
Creates new range position..position+length-1.- Parameters:
position
- the starting range position.length
- the length of range.- Returns:
- new range instance.
- Throws:
IllegalArgumentException
- of position or length is negative.
-
position
public long position()Returns the starting range position.- Returns:
- the starting range position.
-
length
public long length()Returns the range length.- Returns:
- the range length.
-
compareTo
Returns -1 if the starting position of this range is less than the starting position of the argument, 1 if it is greater and 0 if they are equal.- Specified by:
compareTo
in interfaceComparable<DataFile.Range>
- Parameters:
o
- another range.- Returns:
- -1 if the starting position of this range is less than the starting position of the argument, 1 if it is greater and 0 if they are equal.
-
toString
Returns a brief string description of this factory.The result of this method may depend on implementation.
-
hashCode
public int hashCode()Returns the hash code for this range. -
equals
Indicates whether some other range is equal to this one, i.e. it contains the same starting position and length.
-