Hi, ich soll folgende Aufgabenstellung lösen:
Write the interface for a generic collection featuring sorted insertion, deletion and an iterator (java.lang.Iterator), that provides the entries in the collection in sorted order (you do not need to implement the remove method of the iterator).
Write a sorted list class that implements your interface. Test your class, and demonstrate that the "new" form of the for loop works with your class.
Hint: The type of the entries in the collection shall be restricted to a subtype of Comparable <...>. Don't leave any types unspecified. Do not use any ready made collection class.
Hab mal mit dem Interface angefangen, aber schon hier habe ich Probleme. Das hab ich bisher:
Was nichts anderes bedeutet, als die wichtigsten Methoden von Collection und Iterator ... ist das bisher so in etwa korrekt oder bin ich da komplett auf dem Holzweg? So ganz verstehe ich die Aufgabenstellung nämlich nicht wirklich ???:L
Im Übrigen ist mir völlig unklar, was mit "new form of the for loop" gemeint ist ???:L
Wäre für jede Hilfe dankbar!
Write the interface for a generic collection featuring sorted insertion, deletion and an iterator (java.lang.Iterator), that provides the entries in the collection in sorted order (you do not need to implement the remove method of the iterator).
Write a sorted list class that implements your interface. Test your class, and demonstrate that the "new" form of the for loop works with your class.
Hint: The type of the entries in the collection shall be restricted to a subtype of Comparable <...>. Don't leave any types unspecified. Do not use any ready made collection class.
Hab mal mit dem Interface angefangen, aber schon hier habe ich Probleme. Das hab ich bisher:
Java:
public interface GenericCollection<E> {
int size();
boolean isEmpty();
void add(E element); // ensures that this collection contains the specified element
boolean contains(Object element);
boolean remove (Object element); // removes a single instance of the specified element from this collection
Iterator<E> iterator(); // returns an iterator over the elements in this collection
boolean hasNext(); // returns true if the iteration has more elements
Object next(); // returns the next element in the iteration
}
Was nichts anderes bedeutet, als die wichtigsten Methoden von Collection und Iterator ... ist das bisher so in etwa korrekt oder bin ich da komplett auf dem Holzweg? So ganz verstehe ich die Aufgabenstellung nämlich nicht wirklich ???:L
Im Übrigen ist mir völlig unklar, was mit "new form of the for loop" gemeint ist ???:L
Wäre für jede Hilfe dankbar!