Class DataFile.Range

java.lang.Object
net.algart.arrays.DataFile.Range
All Implemented Interfaces:
Comparable<DataFile.Range>
Enclosing interface:
DataFile

public static final class DataFile.Range extends Object implements Comparable<DataFile.Range>

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 Type
    Method
    Description
    int
    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
    Returns the hash code for this range.
    long
    Returns the range length.
    long
    Returns the starting range position.
    Returns a brief string description of this factory.
    valueOf(long position, long length)
    Creates new range position..position+length-1.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • valueOf

      public static DataFile.Range valueOf(long position, long length)
      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

      public int compareTo(DataFile.Range o)
      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 interface Comparable<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

      public String toString()
      Returns a brief string description of this factory.

      The result of this method may depend on implementation.

      Overrides:
      toString in class Object
      Returns:
      a brief string description of this object.
    • hashCode

      public int hashCode()
      Returns the hash code for this range.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code for this range.
    • equals

      public boolean equals(Object obj)
      Indicates whether some other range is equal to this one, i.e. it contains the same starting position and length.
      Overrides:
      equals in class Object
      Parameters:
      obj - some another range.
      Returns:
      true if the passed object is an instance of this class and contains the same starting position and length.