|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkodkod.instance.Universe
public final class Universe
Represents an ordered set of unique atoms. Objects used as atoms must properly
implement equals
and hashCode
methods. The behavior of a universe is not specified if the value of an object is changed in a
manner that affects equals comparisons while the object is an atom in the universe.
Each universe provides a tuple factory
to facilitate creation of tuples
and
sets of tuples
based on the atoms in the universe.
Implementation Note: although the atoms in a universe are not interpreted in any way by the Kodkod engine, it is strongly recommended that the atoms of the same 'type' be grouped together. For instance, suppose that a client model is specified in terms of disjoint types Person = {Person0, Person1, Person2} and Dog = {Dog0, Dog1}. Then, the client may observe an improvement in performance if he constructs the universe over the sequences {Person0, Person1, Person2, Dog0, Dog1} or {Dog0, Dog1, Person0, Person1, Person2} rather than any other permutation of these five atoms.
factory = (TupleFactory<:universe).this |
size > 0 |
size: int |
atoms: [0..size)->one Object |
factory: TupleFactory |
Constructor Summary | |
---|---|
Universe(java.util.Collection<?> atoms)
Constructs a new Universe consisting of the given atoms, in the order that they are returned by the specified Collection's Iterator. |
Method Summary | |
---|---|
java.lang.Object |
atom(int i)
Returns the i_th atom in this universe |
boolean |
contains(java.lang.Object atom)
Returns true if atom is in this universe, otherwise returns false. |
TupleFactory |
factory()
Returns a TupleFactory that can be used to construct tuples and sets of tuples based on this universe. |
int |
index(java.lang.Object atom)
Returns the index of the specified atom in this universe; if the atom is not in this universe, an IllegalArgumentException is thrown. |
java.util.Iterator<java.lang.Object> |
iterator()
Returns an iterator over atoms in this universe, according to their order in the universe. |
int |
size()
Returns the size of this universe |
java.lang.String |
toString()
Returns a string representation of this universe. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Universe(java.util.Collection<?> atoms)
java.lang.NullPointerException
- - atoms = null
java.lang.IllegalArgumentException
- - atoms contains duplicates
java.lang.IllegalArgumentException
- - atoms is emptythis.size' = atoms.size && this.atoms' = atoms.iterator |
Method Detail |
---|
public TupleFactory factory()
public int size()
public boolean contains(java.lang.Object atom)
public java.lang.Object atom(int i)
java.lang.IndexOutOfBoundsException
- - i < 0 || i >= this.sizepublic int index(java.lang.Object atom)
java.lang.IllegalArgumentException
- - no this.atoms.atompublic java.util.Iterator<java.lang.Object> iterator()
iterator
in interface java.lang.Iterable<java.lang.Object>
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |