54 lines
1.5 KiB
54 lines
1.5 KiB
package solution;
|
|
|
|
import java.util.Collection;
|
|
import java.util.Comparator;
|
|
|
|
public interface ISimpleList<E> {
|
|
|
|
// Anzahl der Elemente in der Liste
|
|
int size();
|
|
|
|
// fügt das Element e am Ende der Liste ein, sofern es ungleich null ist:
|
|
// Liefert true, falls ein Element eingefügt wurde (false sonst)
|
|
boolean add(E e);
|
|
|
|
// fügt alle Elemente der Collection c ein (sofern diese nicht null sind).
|
|
boolean add(Collection<E> c);
|
|
|
|
// prüft, ob das Objekt o in der Liste enthalten ist (o == null führt zur
|
|
// Rückgabe false)
|
|
boolean contains(Object o);
|
|
|
|
// entfernt das Objekt o aus der Liste // true: Ein Element wurde entfernt,
|
|
// false sonst
|
|
boolean remove(Object o);
|
|
|
|
// Durchläuft alle Elemente der Liste und wendet command.execute auf jedes
|
|
// Element an
|
|
void forAll(ICommand<E> command);
|
|
|
|
// fügt das Element an der Position i ein, sofern es nicht null ist und 0 <= i
|
|
// <= Anzahl an Elementen gilt. Rückgabe true, false sonst.
|
|
default void add(int i, E e) throws IndexOutOfBoundsException {
|
|
}
|
|
|
|
// Liefert das Element, das an Position i steht, null falls i keinen gültigen
|
|
// Index darstellt.
|
|
default E get(int i) throws IndexOutOfBoundsException {
|
|
return null;
|
|
}
|
|
|
|
// Ersetzt das i-te Element durch e, sofern es vorhanden ist (Index gültig)
|
|
default void set(int i, E e) throws IndexOutOfBoundsException {
|
|
}
|
|
|
|
// Löscht das i-te Element, sofern der Index gültig ist. Rückgabe true, false
|
|
// sonst.
|
|
default boolean remove(int i) {
|
|
return false;
|
|
}
|
|
|
|
// Sortiermethode mittels Comparator
|
|
default void sort(Comparator<E> comparator) {
|
|
}
|
|
}
|