it.unimi.dsi.mg4j.search
Class Interval

java.lang.Object
  extended byit.unimi.dsi.mg4j.search.Interval
All Implemented Interfaces:
Serializable

public final class Interval
extends Object
implements Serializable

An integral interval. An interval is defined by two integers, called its left and right extremes.

This class has no constructor: use the static factories getInstance(int, int) and getInstance(int), instead.

Instances of this class are immutable. To reduce garbage collection, intervals made of one non-negative small points are precomputed and returned upon request.

See Also:
Serialized Form

Field Summary
 int left
          The left extreme of the interval.
 int right
          The right extreme of the interval.
 
Method Summary
 boolean equals(Object o)
           
static Interval getInstance(int point)
          Returns a one-point interval.
static Interval getInstance(int left, int right)
          Returns an interval with given extremes.
 int hashCode()
           
 int length()
          Returns the interval length, that is, the number of integers contained in the interval.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

left

public final int left
The left extreme of the interval.


right

public final int right
The right extreme of the interval.

Method Detail

getInstance

public static Interval getInstance(int left,
                                   int right)
Returns an interval with given extremes.

Parameters:
left - the left extreme.
right - the right extreme (which must be greater than or equal to the left extreme).
Returns:
an interval with the given extremes.

getInstance

public static Interval getInstance(int point)
Returns a one-point interval.

Parameters:
point - a point.
Returns:
a one-point interval

length

public int length()
Returns the interval length, that is, the number of integers contained in the interval.

Returns:
the interval length.

toString

public String toString()

hashCode

public int hashCode()

equals

public boolean equals(Object o)