java.lang.Cloneable
public class SetInterval
extends java.lang.Object
implements java.lang.Cloneable
Interval
but over sets of
integers instead of over integers. The partial ordering of the elements of set intervals is the "subset" relation.
Set intervals are intervals of the form [A, B]
in which A, B
are sets of integers.
If A
is not a subset of B
then the writing above represents the empty set.
If A = B
the writing above represents the singleton {A}
.
If A
is a (strict) subset of B
then the interval represents the set of all sets of integers
that contain or are equal to A
and that are contained by or equal to B
.
More formally: [A,B] = {X | A subset X subset B}
.
A set of integers X
is an element of [A,B]
if and only if
X
is a subset of B
and A
is a subset of X
.Modifier and Type | Field | Description |
---|---|---|
static MultiInterval |
INF |
Infimum, least possible set (empty set).
|
static MultiInterval |
SUP |
Supremum, greatest possible set (universe).
|
Constructor | Description |
---|---|
SetInterval() |
Constructs an empty set interval.
|
SetInterval(java.util.Collection<MultiInterval> multiIntervals) |
Constructs the minimum set interval that contains all multi-intervals in
multiIntervals . |
SetInterval(MultiInterval multiInterval) |
Constructs a set interval which has only one element, i.e.
|
SetInterval(MultiInterval lowerBound,
MultiInterval upperBound) |
Creates a set interval of the form
[lowerBound, upperBound] . |
Modifier and Type | Method | Description |
---|---|---|
SetInterval |
clone() |
Creates and returns a copy of
this . |
boolean |
contains(MultiInterval set) |
Tests whether
set is an element of this set interval. |
boolean |
equals(java.lang.Object object) |
Checks whether
this and object are equal. |
MultiInterval |
getGlb() |
Returns the greatest lower bound of
this set interval. |
MultiInterval |
getLub() |
Returns the least upper bound of
this set interval. |
SetInterval |
intersect(SetInterval setInterval) |
Computes and returns the intersection of
this with setInterval |
boolean |
isEmpty() |
Checks whether
this is the empty set or not. |
boolean |
isSingleton() |
Checks whether
this set interval is a singleton, i.e. contains exactly one element. |
boolean |
isUniverse() |
Checks whether
this is the universe. |
double |
size() |
Returns the number of elements in
this set interval. |
java.lang.String |
toString() |
Creates and returns a string representation of
this . |
static SetInterval |
universe() |
Returns a new set interval which is the universe.
|
public static final MultiInterval INF
public static final MultiInterval SUP
public SetInterval()
public SetInterval(@NotNull MultiInterval multiInterval)
multiInterval
If multiInterval
is not a subset of the supremum, SUP
the empty
set interval is created.multiInterval
- the only element of the constructed set interval.public SetInterval(@NotNull MultiInterval lowerBound, @NotNull MultiInterval upperBound)
[lowerBound, upperBound]
.
If lowerBound
and upperBound
are not both subsets of SUP
the empty set interval is created.lowerBound
- greatest lower bound of the set interval.upperBound
- least upper bound of the set interval.public SetInterval(@NotNull java.util.Collection<MultiInterval> multiIntervals)
multiIntervals
.multiIntervals
- collection of multi-intervals.public boolean contains(@NotNull MultiInterval set)
set
is an element of this
set interval.set
- the set of integer to test.true
if set
is an element of this
, false
otherwise.public boolean isEmpty()
this
is the empty set or not.true
if this
is the empty set, false
otherwise.public boolean isSingleton()
this
set interval is a singleton, i.e. contains exactly one element.true
if this
is a singleton, false
otherwise.public boolean isUniverse()
this
is the universe.true
if this
is the universe, false
otherwise.public double size()
this
set interval.this
.@Nullable public MultiInterval getGlb()
this
set interval.this
set interval.
Returns null
if this
is the empty set interval.@Nullable public MultiInterval getLub()
this
set interval.this
set interval.
Returns null
if this
is the empty set interval.@NotNull public static SetInterval universe()
@NotNull public SetInterval intersect(@NotNull SetInterval setInterval)
this
with setInterval
setInterval
- the other argument of the set intersection.@NotNull public SetInterval clone()
this
.this
.public boolean equals(@Nullable java.lang.Object object)
this
and object
are equal.equals
in class java.lang.Object
object
- the object to check for equality.true
if and only if this
is equal
to object
.@NotNull public java.lang.String toString()
this
.
The string returned is "{}" if this
is the empty set,
{A} if glb = lub = A
(this
is a singleton), "[glb..lub]" otherwise.toString
in class java.lang.Object
this
.