sk.uniba.euromath.editor.textEditor
Class Interval

java.lang.Object
  extended by sk.uniba.euromath.editor.textEditor.Interval

public class Interval
extends Object

Interval of non-negative numbers, start index is included in interval, end index not. Range of this interval is positive.

Author:
Tomáš Studva 7.2.2006 Martin Kollar

Constructor Summary
Interval(int start, int end)
          Contructor.
 
Method Summary
 boolean contains(int index)
          Tests if index falls into interval (into or onto bounds)
 boolean contains(Interval interval)
          Tests if this interval contains interval.
 int getEnd()
          Returns ending index.
 int getStart()
          Returns starting index.
 boolean intersects(Interval interval)
          Tests if this interval intersects interval.
static Interval ORIntervals(Interval interval1, Interval interval2)
          Computes OR of two intervals.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Interval

public Interval(int start,
                int end)
Contructor. For interval holds 0 <= start < end.

Parameters:
start - of interval, must be non-negative
end - of interval, greater than start, is not included in interval
Method Detail

getStart

public int getStart()
Returns starting index.

Returns:
starting index

getEnd

public int getEnd()
Returns ending index.

Returns:
ending index

contains

public boolean contains(int index)
Tests if index falls into interval (into or onto bounds)

Parameters:
index - to test
Returns:
true if index is inside of this interval

contains

public boolean contains(Interval interval)
Tests if this interval contains interval.

Parameters:
interval - Interval to test
Returns:
true if interval is inside this interval

intersects

public boolean intersects(Interval interval)
Tests if this interval intersects interval.

Parameters:
interval - Interval to test for inersection
Returns:
true if their intersection is not empty or they are adjacent

ORIntervals

public static Interval ORIntervals(Interval interval1,
                                   Interval interval2)
Computes OR of two intervals. Interval to OR have to intersect.

Parameters:
interval1 -
interval2 -
Returns:
logical OR of this intersecting intervals

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003-2006 null. All Rights Reserved.