|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.decisiondeck.jmcda.structure.graph.Preorder<T>
T - the type of elements on which the relation is defined.public class Preorder<T>
Objects of this class represent a complete preorder, that is, a relation on a set of objects called elements, which can be viewed as an ordered set of classes of equivalence. A class of equivalence is a set of elements that are considered equal by the preorder. All objects in the highest class of equivalence are given the rank number one, all elements in the second highest class of equivalence have the rank two, and so on. As of vocabulary, in this class the highest rank is considered to be the rank one, thus containing the highest elements in terms of this preorder relation.
The lowest possible rank for a set of n elements, if all ranks are occupied, is the rank n . This object does not enforce that every ranks are occupied, thus it can have more ranks than elements.
This object guarantees that any element it contains has only one rank: no two equal elements (in terms of
Object.equals(java.lang.Object)) may occupy two different ranks at the same time.
| Constructor Summary | |
|---|---|
Preorder(int ranks)
Creates a preorder with the given number of ranks. |
|
| Method Summary | |
|---|---|
Set<T> |
get(int rank)
|
Integer |
getRank(T element)
|
int |
getRanksCount()
|
NavigableSet<T> |
getTotalOrder()
Retrieves this preorder content as a total order, if this preorder is a total order (i.e., if there is exactly one element per rank). |
void |
lower(T element)
Lowers the given element by one rank. |
boolean |
put(Set<T> elements,
int rank)
Puts all the elements in the given rank, as per calling repeatedly the method put(Object, int). |
boolean |
put(T element,
int rank)
Adds an element to the set of elements at a given rank. |
void |
raise(T element)
Raises the given element by one rank. |
boolean |
remove(T element)
Removes the given element from this object, if it is present. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Preorder(int ranks)
ranks - a number greater or equal to zero.| Method Detail |
|---|
public boolean remove(T element)
element - not null.
true iff the given element existed in this object.public Set<T> get(int rank)
rank - between 1 and the number of ranks, inclusive. 1 is the best rank.
public boolean put(T element,
int rank)
element - not null.rank - between 1 and the number of ranks, inclusive. 1 is the best, or highest, rank.
true iff the element has been added or moved, thus was not already in the set of elements at
that rank.public void raise(T element)
element - must exist in this object, must not be already at rank one.public Integer getRank(T element)
element - not null.
null iff the given element is not contained in this
object.
public boolean put(Set<T> elements,
int rank)
put(Object, int). Elements
existing at an other rank are moved.
elements - not null, but may be empty.rank - the rank where to put the objects.
true iff the call changed the ranking, thus false iff every elements were
already in the given rank.public void lower(T element)
element - must exist in this object at a rank higher than the lowest one.public int getRanksCount()
public NavigableSet<T> getTotalOrder()
null iff this preorder is not a total order.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||