public class Chain extends AbstractDistributiveLattice
Elements of a chain with n elements are numbered from 0 to n −
1, causing an unfortunate clash between one(), which can be obtained as
valueOf("1"), and the second element (starting from zero())
of the chain, which can be obtained as valueOf(1).
| Constructor and Description |
|---|
Chain(int n)
Create a chain with the given number of elements.
|
Chain(int n,
String... name)
Create a chain with the given number of elements, naming elements with the given strings.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
comp(Element x,
Element y)
Check whether two elements are comparable using
Lattice.meet(Element[]). |
Collection<Element> |
elements()
Generate iteratively all elements of this lattice.
|
Collection<Element> |
generators()
Return a collection of generators for the lattice.
|
Element |
join(Element... element)
Return the join of the provided elements.
|
boolean |
leq(Element x,
Element y)
Check whether an element is smaller than or equal to another element using
Lattice.meet(Element[]). |
Element |
meet(Element... element)
Return the meet of the provided elements.
|
Element |
one()
Return the one of this lattice.
|
String |
toString() |
Element |
valueOf(int i)
Return the element of this chain of given ordinal position.
|
Element |
valueOf(String name)
Return an element of this lattice, given its name.
|
Element |
zero()
Return the zero of this lattice.
|
isDistributivecoveringRelation, ensureElementsInLattice, ensureElementsInLattice, ensureElementsInLattice, pscomp, psdiff, symdiff, valueOfZeroOrOnepublic Chain(int n,
String... name)
public Chain(int n)
n - the number of elements in this chain.public Element valueOf(String name)
LatticeCertain lattices make it possible to define names for elements. This method returns the element corresponding to the provided name.
name - the name of an element of this lattice.name.public Element valueOf(int i)
Note that while valueOf(0) return zero(),
valueOf(1) will not return one() unless this
chain has less than three elements.
i - the ordinal position in this chain (starting at zero() with position 0).i.public Collection<Element> generators()
Latticezero or
one. There is no guarantee of freeness or minimality.public Collection<Element> elements()
AbstractLatticeThis methods uses Lattice.generators() to obtain an initial set of elements,
and then computes joins and meets of all available elements until no new elements
are generated.
It is expected that concrete subclasses will override this method
with an ad hoc, more efficient implementation.
It is strongly suggested that concrete subclasses that do not override this method cache its result internally.
elements in interface Latticeelements in class AbstractLatticepublic Element one()
LatticeNote that there is no guarantee that the returned element is the only element representing one in this lattice. Other ones may arise from computations, but they will always be equal to the element returned by this method.
public Element zero()
LatticeNote that there is no guarantee that the returned element is the only element representing zero in this lattice. Other zeroes may arise from computations, but they will always be equal to the element returned by this method.
public Element join(Element... element)
Latticezero, and upon a singleton list the only specified element.element - the elements whose join has to be computed.public Element meet(Element... element)
Latticeone, and upon a singleton list the only specified element.element - the elements whose meet has to be computed.public boolean comp(Element x, Element y)
AbstractLatticeLattice.meet(Element[]).comp in interface Latticecomp in class AbstractLatticex - an element.y - another element.x.meet(y) equals x or y.public boolean leq(Element x, Element y)
AbstractLatticeLattice.meet(Element[]).leq in interface Latticeleq in class AbstractLatticex - an element.y - another element.x.meet(y) equals x.