java.lang.Cloneable
, java.lang.Iterable<java.lang.Object>
public class LSet extends LCollection implements java.lang.Cloneable
USEJOLLYTOKEN
Constructor | Description |
---|---|
LSet() |
Constructs an unspecified logical set with default name.
|
LSet(java.lang.String name) |
Constructs an unspecified logical set with given name.
|
LSet(java.lang.String name,
java.util.Set<?> set) |
Constructs a bound and closed logical set whose elements are those in
set and with a given name. |
LSet(java.lang.String name,
LSet lSet) |
Constructs a logical set which is equal to the parameter
set and with given name. |
LSet(java.util.Set<?> set) |
Constructs a bound and closed logical set whose elements are those in
set and with a default name. |
LSet(LSet lSet) |
Constructs a logical set which is equal to the parameter
lSet and with default name. |
Modifier and Type | Method | Description |
---|---|---|
java.lang.Object |
accept(jsetl.Visitor visitor) |
Implementation of this method is needed for the Visitor design pattern.
|
LSet |
clone() |
Creates and returns a copy of this logical set.
|
Constraint |
contains(java.lang.Object object) |
Returns a constraint conjunction whose sole atomic constraint demands that
object is an element of this . |
Constraint |
diff(java.util.Set<?> set1,
java.util.Set<?> set2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - set1 == set2 . |
Constraint |
diff(java.util.Set<?> set,
LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - set == lSet . |
Constraint |
diff(LSet lSet,
java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - lSet == set . |
Constraint |
diff(LSet lSet1,
LSet lSet2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - lSet1 == lSet2 . |
Constraint |
disj(java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this and set are disjoint. |
Constraint |
disj(LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this and lSet are disjoint. |
static LSet |
empty() |
Creates and returns an empty logical set (completely specified).
|
Constraint |
eq(java.util.Set<?> set) |
Constructs and returns a new constraint which demands that
this is equal to set |
Constraint |
eq(LSet lSet) |
Constructs and returns a new constraint which demands that
this is equal to lSet . |
boolean |
equals(java.lang.Object object) |
Checks whether this
LSet is equal to the specified Object . |
int |
getSize() |
Returns the number of distinct elements of this logical set
(0 for the empty or uninitialized logical set).
|
LSet |
getTail() |
Gets the tail of this
LSet . |
java.util.HashSet<?> |
getValue() |
Gets the value of this
LSet (i.e., a HashSet object containing all the
elements of this LSet (ignores the unspecified rest of the LSet ,
if present)). |
LSet |
ins(java.lang.Object... objects) |
Creates and returns a new logical set obtained from the union of
this with {object} . |
LSet |
insAll(java.lang.Object[] objects) |
Creates and returns a new logical set obtained from this by adding all
elements of the parameter
objects . |
LSet |
insAll(java.util.Collection<?> newElements) |
Creates and returns a new logical set obtained from this by adding all
elements of the parameter
newElements . |
Constraint |
inters(java.util.Set<?> set1,
java.util.Set<?> set2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this intersection set1 == set2 . |
Constraint |
inters(java.util.Set<?> set,
LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this intersection set == lSet . |
Constraint |
inters(LSet lSet,
java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this intersection lSet == set . |
Constraint |
inters(LSet lSet1,
LSet lSet2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this intersection lSet1 == lSet2 . |
Constraint |
less(java.lang.Object object,
java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - {object} == set . |
Constraint |
less(java.lang.Object object,
LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - {object} == lSet . |
Constraint |
less(LVar lVar,
java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - {lVar} == set . |
Constraint |
less(LVar lVar,
LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - {lVar} == lSet . |
static LSet |
mkSet(int numberOfElements) |
Constructs and returns a closed logical set containing
numberOfElements unbound LVars . |
Constraint |
ncontains(java.lang.Object object) |
Returns a constraint conjunction whose sole atomic constraint demands that
object is not an element of this . |
Constraint |
ndiff(java.util.Set<?> set1,
java.util.Set<?> set2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - set1 != set2 . |
Constraint |
ndiff(java.util.Set<?> set,
LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - set != lSet . |
Constraint |
ndiff(LSet lSet,
java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - lSet != set . |
Constraint |
ndiff(LSet lSet1,
LSet lSet2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this - lSet1 != lSet2 . |
Constraint |
ndisj(java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this and set are not disjoint. |
Constraint |
ndisj(LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this and lSet are not disjoint. |
Constraint |
neq(java.util.Set<?> set) |
Constructs and returns a new constraint which demands that
this is not equal to set |
Constraint |
neq(LSet lSet) |
Constructs and returns a new constraint which demands that
this is not equal to lSet . |
Constraint |
ninters(java.util.Set<?> set1,
java.util.Set<?> set2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this intersection set1 != set2 . |
Constraint |
ninters(java.util.Set<?> set,
LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this intersection set != lSet . |
Constraint |
ninters(LSet lSet,
java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this intersection lSet != set . |
Constraint |
ninters(LSet lSet1,
LSet lSet2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this intersection lSet1 != lSet2 . |
LSet |
normalizeSet() |
Creates and returns a logical set which has the same elements (without duplicates) and tail as
this . |
Constraint |
nsubset(java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this is not a subset of set . |
Constraint |
nsubset(LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this is not a subset of lSet . |
Constraint |
nunion(java.util.Set<?> set1,
java.util.Set<?> set2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this union set1 != set2 . |
Constraint |
nunion(java.util.Set<?> set,
LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this union set != lSet . |
Constraint |
nunion(LSet lSet,
java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this union lSet != set . |
Constraint |
nunion(LSet lSet1,
LSet lSet2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this union lSet1 != lSet2 . |
boolean |
occurs(java.lang.Object object) |
Tests if
object is part of this collection (an element, the tail, or a part of an element). |
void |
printElems(char c) |
Prints all the (known) elements of this logical set to standard output.
|
LSet |
setName(java.lang.String name) |
Sets the name of this logical object and returns
this logical set. |
LSet |
setValue(java.util.Set<?> set) |
Sets the value of this
LSet to the parameter java set. |
Constraint |
size(java.lang.Integer size) |
Returns a constraint conjunction whose sole atomic constraint demands that
cardinality(this) == size . |
Constraint |
size(IntLVar size) |
Returns a constraint conjunction whose sole atomic constraint demands that
cardinality(this) == size . |
Constraint |
subset(java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this is a subset of set . |
Constraint |
subset(LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this is a subset of lSet . |
java.lang.String |
toString() |
Returns a string corresponding to the logical set value.
|
Constraint |
union(java.util.Set<?> set1,
java.util.Set<?> set2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this union set1 == set2 . |
Constraint |
union(java.util.Set<?> set,
LSet lSet) |
Returns a constraint conjunction whose sole atomic constraint demands that
this union set == lSet . |
Constraint |
union(LSet lSet,
java.util.Set<?> set) |
Returns a constraint conjunction whose sole atomic constraint demands that
this union lSet == set . |
Constraint |
union(LSet lSet1,
LSet lSet2) |
Returns a constraint conjunction whose sole atomic constraint demands that
this union lSet1 == lSet2 . |
forallElems, isClosed, isEmpty, isGround, iterator, testContains, toArray
public LSet()
public LSet(@NotNull java.lang.String name)
name
- name of the logical set.public LSet(@NotNull java.util.Set<?> set)
set
and with a default name.set
- a java set whose elements will be the elements of the constructed logical set.
It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.public LSet(@NotNull java.lang.String name, @NotNull java.util.Set<?> set)
set
and with a given name.set
- a java set whose elements will be the elements of the constructed logical set.
It must not contain null
values.name
- the name of the logical set.java.lang.NullPointerException
- if set
contains null
values.public LSet(@NotNull LSet lSet)
lSet
and with default name.
This constructor is equivalent to solving the constraint this.eq(lSet)
.lSet
- the logical set to which the constructed logical set is equal.public LSet(@NotNull java.lang.String name, @NotNull LSet lSet)
set
and with given name.
This constructor is equivalent to solving the constraint this.eq(lSet)
.name
- name of the logical set.lSet
- the set to which the constructed logical set is equal.@NotNull public static LSet empty()
@NotNull public static LSet mkSet(int numberOfElements)
numberOfElements
unbound LVars
.numberOfElements
- number of unbound LVars
. Must be greater than or equal to zero.java.lang.IllegalArgumentException
- if numberOfElements
is negative.@Nullable public java.lang.Object accept(@NotNull jsetl.Visitor visitor)
visitor
- the visitor that wants to visit the object.visitor.visit(this)
.@NotNull public LSet setName(@NotNull java.lang.String name)
this
logical set.@NotNull public LSet ins(@NotNull java.lang.Object... objects)
this
with {object}
.
The invocation object is not modified.objects
- the object to use when creating the new set.object
to this logical set.java.lang.NullPointerException
- if objects
contains null
values.@NotNull public LSet insAll(@NotNull java.lang.Object[] objects)
objects
. Does not modify this logical object.objects
- array of elements to add. None of its elements can be null
.java.lang.NullPointerException
- if at least one of the elements in objects
is null
.@NotNull public LSet insAll(@NotNull java.util.Collection<?> newElements)
newElements
. Does not modify this logical set.newElements
- collection of elements to add. None of its elements can be null
.java.lang.NullPointerException
- if at least one of the elements in newElements
is null
.@NotNull public LSet clone()
public boolean equals(@Nullable java.lang.Object object)
LSet
is equal to the specified Object
.
The objects are equal when:
- they are the same object or reference to the same object,
even if the object or the reference are not initialized,
- they contain equal objects or they contain references to
equal objects (order does not matter!)
(ignores the unspecified rest of the LSet if present)equals
in class java.lang.Object
object
- the tested object.true
if the objects are equal, false
otherwise.@Nullable public java.util.HashSet<?> getValue()
LSet
(i.e., a HashSet
object containing all the
elements of this LSet
(ignores the unspecified rest of the LSet
,
if present)). The result is null
if and only if this logical set is not bound.
The returned set does not contain null
values;@NotNull public LSet setValue(@NotNull java.util.Set<?> set)
LSet
to the parameter java set.
This set becomes bound and closed.
Calling this method is equivalent to solving the constraint this.eq(s)
.set
- the set containing all elements of this logical set. It must not contain null
values.LSet
modified.java.lang.NullPointerException
- if at least one of the elements of set
is null
.InitLObjectException
- if this logical set is already bound.@NotNull public java.lang.String toString()
toString()
to the rest of this collection, if r is not empty.toString
in class LCollection
public void printElems(char c)
printElems
in class LCollection
c
- character used between elements to separate them from each other.public boolean occurs(@NotNull java.lang.Object object)
object
is part of this collection (an element, the tail, or a part of an element).object
- object to search deeply inside this logical collection.true
if object
is an element of this collection, false
otherwise.@Nullable public LSet getTail()
LSet
. The tail can be either
the empty logical set (closed logical set) or an uninitialized
LSet
(open logical set).public int getSize()
getSize
in class LCollection
@NotNull public LSet normalizeSet()
this
.
Does not modify this
logical set.@NotNull public Constraint eq(@NotNull LSet lSet)
this
is equal to lSet
.lSet
- second parameter of the constraint.@NotNull public Constraint eq(@NotNull java.util.Set<?> set)
this
is equal to set
set
- second parameter of the constraint. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint neq(@NotNull LSet lSet)
this
is not equal to lSet
.lSet
- second parameter of the constraint.@NotNull public Constraint neq(@NotNull java.util.Set<?> set)
this
is not equal to set
set
- second parameter of the constraint. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint contains(@NotNull java.lang.Object object)
object
is an element of this
.object
- object who should be an element of this set.@NotNull public Constraint ncontains(@NotNull java.lang.Object object)
object
is not an element of this
.object
- object who should not be an element of this set.@NotNull public Constraint diff(@NotNull LSet lSet1, @NotNull LSet lSet2)
this - lSet1 == lSet2
.lSet1
- second argument of set difference.lSet2
- result of set difference.@NotNull public Constraint diff(@NotNull LSet lSet, @NotNull java.util.Set<?> set)
this - lSet == set
.lSet
- second argument of set difference.set
- result of set difference. It must not contain null values
.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint diff(@NotNull java.util.Set<?> set, @NotNull LSet lSet)
this - set == lSet
.set
- second argument of set difference. It must not contain null
values.lSet
- result of set difference.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint diff(@NotNull java.util.Set<?> set1, @NotNull java.util.Set<?> set2)
this - set1 == set2
.set1
- second argument of set difference. It must not contain null
values.set2
- result of set difference. It must not contain null
values.java.lang.NullPointerException
- if set1
or set2
contain null
values.@NotNull public Constraint disj(@NotNull LSet lSet)
this
and lSet
are disjoint.
Note that two sets are said to be disjoint if and only if they have no element in common.lSet
- the set which should be disjoint to this
.@NotNull public Constraint disj(@NotNull java.util.Set<?> set)
this
and set
are disjoint.
Note that two sets are said to be disjoint if and only if they have no element in common.set
- the set which should be disjoint to this
. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint inters(@NotNull LSet lSet1, @NotNull LSet lSet2)
this intersection lSet1 == lSet2
.
This means that lSet2
is equal to the intersection of this
and lSet1
, i.e.,
for all x: x in lSet2
iff x in this
and x in lSet1
.lSet1
- second argument of set intersection.lSet2
- result of set intersection.@NotNull public Constraint inters(@NotNull LSet lSet, @NotNull java.util.Set<?> set)
this intersection lSet == set
.
This means that set
is equal to the intersection of this
and lSet
, i.e.,
for all x: x in set
iff x in this
and x in lSet
.lSet
- second argument of set intersection.set
- result of set intersection. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint inters(@NotNull java.util.Set<?> set, @NotNull LSet lSet)
this intersection set == lSet
.
This means that lSet
is equal to the intersection of this
and set
, i.e.,
for all x: x in lSet
iff x in this
and x in set
.set
- second argument of set intersection. It must not contain null
values.lSet
- result of of set intersection.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint inters(@NotNull java.util.Set<?> set1, @NotNull java.util.Set<?> set2)
this intersection set1 == set2
.
This means that set2
is equal to the intersection of this
and set1
, i.e.,
for all x: x in set2
iff x in this
and x in set1
.set1
- second argument of set intersection. It must not contain null
values.set2
- result of set intersection. It must not contain null
values.java.lang.NullPointerException
- if set1
or set2
contain null
values.@NotNull public Constraint less(@NotNull LVar lVar, @NotNull LSet lSet)
this - {lVar} == lSet
.lVar
- the only element of the second argument of the set difference.lSet
- result of set difference.@NotNull public Constraint less(@NotNull java.lang.Object object, @NotNull LSet lSet)
this - {object} == lSet
.object
- the only element of the second argument of the set difference.lSet
- result of of set difference.@NotNull public Constraint less(@NotNull LVar lVar, @NotNull java.util.Set<?> set)
this - {lVar} == set
.lVar
- the only element of the second argument of the set difference.set
- result of set difference. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint less(@NotNull java.lang.Object object, @NotNull java.util.Set<?> set)
this - {object} == set
.object
- the only element of the second argument of the set difference.set
- result of set difference. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint size(@NotNull IntLVar size)
cardinality(this) == size
.size
- the cardinality of this
logical set.@NotNull public Constraint size(@NotNull java.lang.Integer size)
cardinality(this) == size
.size
- the cardinality of this
logical set.@NotNull public Constraint subset(@NotNull LSet lSet)
this
is a subset of lSet
.lSet
- the other argument of the subset constraint.@NotNull public Constraint subset(@NotNull java.util.Set<?> set)
this
is a subset of set
.set
- the other argument of the subset constraint. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint union(@NotNull LSet lSet1, @NotNull LSet lSet2)
this union lSet1 == lSet2
.lSet1
- second argument of set union.lSet2
- result of set union.@NotNull public Constraint union(@NotNull LSet lSet, @NotNull java.util.Set<?> set)
this union lSet == set
.lSet
- second argument of set union.set
- result of set union. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint union(@NotNull java.util.Set<?> set, @NotNull LSet lSet)
this union set == lSet
.set
- second argument of set union. It must not contain null
values.lSet
- result of set union.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint union(@NotNull java.util.Set<?> set1, @NotNull java.util.Set<?> set2)
this union set1 == set2
.set1
- second argument of set union. It must not contain null
values.set2
- result of set union. It must not contain null
values.java.lang.NullPointerException
- if set1
or set2
contain null
values.@NotNull public Constraint nunion(@NotNull LSet lSet1, @NotNull LSet lSet2)
this union lSet1 != lSet2
.lSet1
- second argument of set union.lSet2
- different than the result of of set union.@NotNull public Constraint nunion(@NotNull LSet lSet, @NotNull java.util.Set<?> set)
this union lSet != set
.lSet
- second argument of set union.set
- different than the result of set union. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint nunion(@NotNull java.util.Set<?> set, LSet lSet)
this union set != lSet
.set
- second argument of set union. It must not contain null
values.lSet
- different than the result of set union.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint nunion(@NotNull java.util.Set<?> set1, @NotNull java.util.Set<?> set2)
this union set1 != set2
.set1
- second argument of set union. It must not contain null
values.set2
- different than the result of set union. It must not contain null
values.java.lang.NullPointerException
- if set1
or set2
contain null
values.@NotNull public Constraint ndisj(@NotNull LSet lSet)
this
and lSet
are not disjoint.
Note that two sets are not disjoint if and only if they have at least one element in common.lSet
- the set which should be disjoint to this
.@NotNull public Constraint ndisj(@NotNull java.util.Set<?> set)
this
and set
are not disjoint.
Note that two sets are not disjoint if and only if they have at least one element in common.set
- the set which should be disjoint to this
. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint nsubset(@NotNull LSet lSet)
this
is not a subset of lSet
.lSet
- the other argument of the not subset constraint.@NotNull public Constraint nsubset(@NotNull java.util.Set<?> set)
this
is not a subset of set
.set
- the other argument of the not subset constraint. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint ninters(@NotNull LSet lSet1, @NotNull LSet lSet2)
this intersection lSet1 != lSet2
.
This means that lSet2
is not equal to the intersection of this
and lSet1
.lSet1
- second argument of set intersection.lSet2
- different than the result of set intersection.@NotNull public Constraint ninters(@NotNull LSet lSet, @NotNull java.util.Set<?> set)
this intersection lSet != set
.
This means that set
is not equal to the intersection of this
and lSet
.lSet
- second argument of set intersection.set
- different than the result of set intersection. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint ninters(@NotNull java.util.Set<?> set, @NotNull LSet lSet)
this intersection set != lSet
.
This means that lSet
is not equal to the intersection of this
and set
.set
- second argument of set intersection. It must not contain null
values.lSet
- different than the result of set intersection.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint ninters(@NotNull java.util.Set<?> set1, @NotNull java.util.Set<?> set2)
this intersection set1 != set2
.
This means that set2
is not equal to the intersection of this
and set1
.set1
- second argument of set intersection. It must not contain null
values.set2
- different than the result of set intersection. It must not contain null
values.java.lang.NullPointerException
- if set1
or set2
contain null
values.@NotNull public Constraint ndiff(@NotNull LSet lSet1, @NotNull LSet lSet2)
this - lSet1 != lSet2
.lSet1
- second argument of set difference.lSet2
- different than the result of set difference.@NotNull public Constraint ndiff(@NotNull LSet lSet, @NotNull java.util.Set<?> set)
this - lSet != set
.lSet
- second argument of set difference.set
- different than the result of set difference. It must not contain null
values.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint ndiff(@NotNull java.util.Set<?> set, @NotNull LSet lSet)
this - set != lSet
.set
- second argument of set difference. It must not contain null
values.lSet
- different than the result of set difference.java.lang.NullPointerException
- if set
contains null
values.@NotNull public Constraint ndiff(@NotNull java.util.Set<?> set1, @NotNull java.util.Set<?> set2)
this - set1 != set2
.set1
- second argument of set difference. It must not contain null
values.set2
- different than the result of set difference. It must not contain null
values.java.lang.NullPointerException
- if set1
or set2
contain null
values.