java.lang.Cloneable
, java.lang.Iterable<java.lang.Object>
public abstract class LCollection extends LObject implements java.lang.Cloneable, java.lang.Iterable<java.lang.Object>
USEJOLLYTOKEN
Modifier and Type | Method | Description |
---|---|---|
Constraint |
forallElems(LVar y,
Constraint constraint) |
Constructs a conjunction of constraints
constraint [y substituted with e_i] for all
elements e_i of this LCollection , where constraint [y substituted with e_i] is the constraint
obtained from constraint by replacing all occurrences of the LVar y with e_i. |
int |
getSize() |
Returns the number of (possibly repeated) elements of the collection.
|
boolean |
isClosed() |
Returns
true if the tail of this logical collection is the empty
collection (= closed collection); otherwise it returns false |
boolean |
isEmpty() |
Tests if this logical collection is bound and empty.
|
boolean |
isGround() |
Tests if this
LCollection contains any non-ground logical object. |
java.util.Iterator<java.lang.Object> |
iterator() |
Returns an iterator over all elements of this collection.
|
void |
printElems(char separator) |
Prints all elements of this
LCollection . |
boolean |
testContains(java.lang.Object object) |
Tests whether the parameter is an element of this logical collection.
|
java.lang.Object[] |
toArray() |
This method puts each known element of the collection (ignoring its tail) into an array of objects.
|
java.lang.String |
toString() |
Returns a string corresponding to the object value.
|
@NotNull public java.lang.String toString()
toString()
to the rest of this collection, if r is not empty.toString
in class java.lang.Object
public int getSize() throws NotInitLObjectException
0
for the empty
collection.
Note that it ignores the possibly unspecified tail of the collection.NotInitLObjectException
- if the collection is unbound.public boolean isClosed()
true
if the tail of this logical collection is the empty
collection (= closed collection); otherwise it returns false
true
if the collection is closed, false
otherwise.public boolean isEmpty() throws NotInitLObjectException
true
if and only if this LCollection
is bound and has no elements,
that is, its size is zero; false
if it bound and has at least one element.NotInitLObjectException
- if this logical collection is unbound.public boolean isGround()
LCollection
contains any non-ground logical object.@NotNull public java.util.Iterator<java.lang.Object> iterator()
iterator
in interface java.lang.Iterable<java.lang.Object>
public void printElems(char separator)
LCollection
.
All elements are separated by the
character separator
(ignores the unspecified tail of the LCollection
,
if present).separator
- character used to separate elements from each other in the output.public boolean testContains(@NotNull java.lang.Object object)
object
- the object to test for inclusion.true
if the parameter is an element of this logical collection, false
otherwise.@NotNull public java.lang.Object[] toArray()
@NotNull public Constraint forallElems(@NotNull LVar y, @NotNull Constraint constraint) throws NotInitLObjectException
constraint
[y
substituted with e_i] for all
elements e_i of this LCollection
, where constraint
[y
substituted with e_i] is the constraint
obtained from constraint
by replacing all occurrences of the LVar y
with e_i.
For example, if s is {1,2,Z} then s.forallElems(X,X.neq(0))
generates
1 neq 0 and 2 neq 0 and Z neq 0
Note that this method ignores the tail of this logical collection.y
- the dummy logical variable used in the constraint constraint
.constraint
- a constraint conjunction which should be satisfied for each (known) element
of this collection, after substituting y
with them.NotInitLObjectException
- if this
is not bound.InitLObjectException
- if y
is initialized.