org.expasy.jpl.commons.collection
Class Interval

java.lang.Object
  extended by org.expasy.jpl.commons.collection.Interval
All Implemented Interfaces:
Cloneable, DomainOfDefinition<Number>, ExplicitlyCloneable

public final class Interval
extends Object
implements ExplicitlyCloneable, DomainOfDefinition<Number>

An interval is a set of numbers with the property that any number that lies between two numbers is included in the set. An interval is said to be opened ("[]"), closed ("][")or semi-opened ("[[" or "]]") depending on the possible inclusion of bounds. For example, the set of all numbers x satisfying 0 ≤ x < 1 is a semi-opened interval [0, 1[ which contains 0 and not 1, as well as all real numbers between them.

Version:
1.0
Author:
nikitin

Nested Class Summary
static class Interval.Builder
           
static class Interval.IntervalComparator
           
static class Interval.IntervalOverlapException
           
static class Interval.OverlapFinder
           
 
Method Summary
 Interval clone()
          duplicate the object
 boolean contains(Number number)
          Return true if the given number is found in this interval.
static Interval emptyInstance()
           
 double getCenter()
          Get the center value.
 double getLowerBound()
          Get the lower bound number (included).
 int getPrecision()
           
 double getRange()
           
 double getUpperBound()
          Get the upper bound number (excluded).
 boolean hasOverlap(Interval i)
           
 boolean isEmpty()
           
 boolean isLowerBoundIncluded()
           
 boolean isUpperBoundIncluded()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

emptyInstance

public static Interval emptyInstance()

clone

public Interval clone()
Description copied from interface: ExplicitlyCloneable
duplicate the object

Specified by:
clone in interface ExplicitlyCloneable
Overrides:
clone in class Object

getLowerBound

public final double getLowerBound()
Get the lower bound number (included).

Returns:
the lower bound.

getUpperBound

public final double getUpperBound()
Get the upper bound number (excluded).

Returns:
the upper bound.

getCenter

public final double getCenter()
Get the center value.

Returns:
the center value.

isLowerBoundIncluded

public final boolean isLowerBoundIncluded()
Returns:
true if left open interval

isUpperBoundIncluded

public final boolean isUpperBoundIncluded()
Returns:
true if right open interval

contains

public boolean contains(Number number)
Return true if the given number is found in this interval.

Specified by:
contains in interface DomainOfDefinition<Number>
Parameters:
number - the number to test in interval.
Returns:
true if the number is contained in the interval.

getRange

public double getRange()
Returns:
the range of the interval.

getPrecision

public int getPrecision()
Returns:
the maximum significant number of fractional digits.

isEmpty

public boolean isEmpty()
Returns:
true if empty interval.

hasOverlap

public boolean hasOverlap(Interval i)

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.