public class IntervalsList
extends java.lang.Object
An interval list represent a list of contiguous regions on the real line. All intervals of the list are disjoints to each other, they are stored in ascending order.
The class supports the main set operations like union and intersection.
Interval| Constructor and Description |
|---|
IntervalsList()
Build an empty intervals list.
|
IntervalsList(double a,
double b)
Build an intervals list containing only one interval.
|
IntervalsList(Interval i)
Build an intervals list containing only one interval.
|
IntervalsList(Interval i1,
Interval i2)
Build an intervals list containing two intervals.
|
IntervalsList(IntervalsList list)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static IntervalsList |
add(IntervalsList list,
Interval i)
Add an intervals list and an interval.
|
static IntervalsList |
add(IntervalsList list1,
IntervalsList list2)
Add two intervals lists.
|
void |
addToSelf(Interval i)
Add an interval to the instance.
|
void |
addToSelf(IntervalsList list)
Add an intervals list to the instance.
|
boolean |
contains(double x)
Check if the list contains a point.
|
boolean |
contains(Interval i)
Check if the list contains an interval.
|
double |
getInf()
Get the lower bound of the list.
|
Interval |
getInterval(int i)
Get an interval from the list.
|
java.util.List |
getIntervals()
Get the ordered list of disjoints intervals.
|
int |
getSize()
Get the number of intervals of the list.
|
double |
getSup()
Get the upper bound of the list.
|
static IntervalsList |
intersection(IntervalsList list,
Interval i)
Intersect a list and an interval.
|
static IntervalsList |
intersection(IntervalsList list1,
IntervalsList list2)
Intersect two intervals lists.
|
boolean |
intersects(Interval i)
Check if an interval intersects the instance.
|
void |
intersectSelf(Interval i)
Intersects the instance and an interval.
|
void |
intersectSelf(IntervalsList list)
Intersect the instance and another intervals list.
|
boolean |
isConnex()
Check if the instance is connected.
|
boolean |
isEmpty()
Check if the instance is empty.
|
static IntervalsList |
subtract(IntervalsList list,
Interval i)
Remove an interval from a list.
|
static IntervalsList |
subtract(IntervalsList list1,
IntervalsList list2)
Remove an intervals list from another one.
|
void |
subtractFromSelf(Interval i)
Remove an interval from the list.
|
void |
subtractFromSelf(IntervalsList list)
Remove an intervals list from the instance.
|
public IntervalsList()
public IntervalsList(double a,
double b)
a - first bound of the intervalb - second bound of the intervalpublic IntervalsList(Interval i)
i - intervalpublic IntervalsList(Interval i1, Interval i2)
i1 - first intervali2 - second intervalpublic IntervalsList(IntervalsList list)
The copy operation is a deep copy: the underlying intervals are independant of the instances of the copied list.
list - intervals list to copypublic boolean isEmpty()
public boolean isConnex()
An interval list is connected if it contains only one interval.
public double getInf()
public double getSup()
public int getSize()
public Interval getInterval(int i)
i - index of the intervalpublic java.util.List getIntervals()
public boolean contains(double x)
x - point to checkpublic boolean contains(Interval i)
i - interval to checkpublic boolean intersects(Interval i)
i - interval to checkpublic void addToSelf(Interval i)
This method expands the instance.
This operation is a union operation. The number of intervals in the list can decrease if the interval fills some holes between existing intervals in the list.
i - interval to add to the instancepublic static IntervalsList add(IntervalsList list, Interval i)
list - intervals listi - intervalpublic void subtractFromSelf(Interval i)
This method reduces the instance. This operation is defined in terms of points set operation. As an example, if the [2, 3] interval is subtracted from the list containing only the [0, 10] interval, the result will be the [0, 2] U [3, 10] intervals list.
i - interval to removepublic static IntervalsList subtract(IntervalsList list, Interval i)
list - intervals listi - interval to removepublic void intersectSelf(Interval i)
i - intervalpublic static IntervalsList intersection(IntervalsList list, Interval i)
list - intervals listi - intervalpublic void addToSelf(IntervalsList list)
This method expands the instance.
This operation is a union operation. The number of intervals in the list can decrease if the list fills some holes between existing intervals in the instance.
list - intervals list to add to the instancepublic static IntervalsList add(IntervalsList list1, IntervalsList list2)
list1 - first intervals listlist2 - second intervals listpublic void subtractFromSelf(IntervalsList list)
list - intervals list to removepublic static IntervalsList subtract(IntervalsList list1, IntervalsList list2)
list1 - intervals listlist2 - intervals list to removepublic void intersectSelf(IntervalsList list)
list - list to intersect with the instancepublic static IntervalsList intersection(IntervalsList list1, IntervalsList list2)
list1 - first intervals listlist2 - second intervals listCopyright © 2001-2007 Luc Maisonobe. All Rights Reserved.