Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.utils
Class ComparableElement<E,C extends Comparable>

    java.lang.Object
      de.jstacs.utils.ComparableElement<E,C>

Type Parameters:
  `E` - any `Class`

All Implemented Interfaces:
  Comparable<ComparableElement<E,C>>

    public class ComparableElement<E,C extends Comparable>

extends Object
implements Comparable<ComparableElement<E,C>>

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.

Author:
  Jens Keilwagen

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

### ComparableElement

    public ComparableElement(E o,
                             C w)

  Creates a new `ComparableElement`.

  Parameters:
    `o` - the element
    `w` - the weight

Method Detail

### getElement

    public E getElement()

  This method returns the element.

  Returns:
    the element

### getWeight

    public C getWeight()

  This method returns the weight of the element.

  Returns:
    the weight of the element

### compareTo

    public int compareTo(ComparableElement<E,C> o)
                  throws ClassCastException

  Specified by:
    `compareTo` in interface `Comparable<ComparableElement<E,C extends Comparable>>`
  Throws:
    `ClassCastException`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD