|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.utils.ComparableElement<E,C>
E - any ClassC - an implementation of Comparable that is used to compare instance of ComparableElementpublic class ComparableElement<E,C extends Comparable>
This class is a container for any objects that have to be compared. It is
enables you e.g. to use the method Arrays.sort(...) without
writing a comparator. Furthermore it helps to speed up the sorting since the
"weight" can be precomputed and does not have to be recomputed in
every comparison.
| Constructor Summary | |
|---|---|
ComparableElement(E o,
C w)
Creates a new ComparableElement. |
|
| Method Summary | |
|---|---|
int |
compareTo(ComparableElement<E,C> o)
|
E |
getElement()
This method returns the element. |
C |
getWeight()
This method returns the weight of the element. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ComparableElement(E o,
C w)
ComparableElement.
o - the elementw - the weight| Method Detail |
|---|
public E getElement()
public C getWeight()
public int compareTo(ComparableElement<E,C> o)
throws ClassCastException
compareTo in interface Comparable<ComparableElement<E,C extends Comparable>>ClassCastExceptionpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||