Update 9.3.22
parent
1db7d7316d
commit
818be00c30
|
@ -114,7 +114,7 @@ public class LinkedList<A> {
|
|||
return I;
|
||||
}
|
||||
|
||||
public int grˆfle() { // Methode um grˆfle auszugeben
|
||||
public int groeße() { // Methode um grˆfle auszugeben
|
||||
System.out.print("Die Grˆfle der Liste ist: "); //ausgabe
|
||||
System.out.println(size + "\n"); //ausgabe
|
||||
return size; // gibt grˆfle zur¸ck
|
||||
|
|
|
@ -38,13 +38,13 @@ private int size;
|
|||
while (current != null) { // solange current ungleich null ist wird das in der Schleife ausgefÔøΩhrt
|
||||
|
||||
if (current.wert == wert) { // wenn der der Knoten current = der wert ist
|
||||
System.out.println(wert + " " + "ist nicht der Liste");
|
||||
|
||||
return true; // dann gibt es den eintrag also muss er true zurÔøΩckgeben
|
||||
}
|
||||
current = current.next; // n‰chster wert wird zum aktuellen
|
||||
|
||||
}
|
||||
System.out.println(wert + " " + "ist in der Liste");
|
||||
|
||||
return false; // sonst ist er nicht drin
|
||||
}
|
||||
public void remove(P wert) {
|
||||
|
@ -60,6 +60,39 @@ private int size;
|
|||
current = current.next;
|
||||
}
|
||||
}
|
||||
public void Ausgabe() {
|
||||
Node<P> current = this.start;
|
||||
|
||||
while(current != null) {
|
||||
System.out.print(current.wert + " ");
|
||||
current = current.next;
|
||||
} System.out.print("\n");
|
||||
}
|
||||
public int size() { // getter Mehode f¸r grˆfle
|
||||
return this.size;
|
||||
}
|
||||
public Node<P> getStart() { // getter Mehode f¸r Start
|
||||
return this.start;
|
||||
}
|
||||
public Set<P> intersection(Set<P> s) {
|
||||
Set<P> result = new Set<P>();
|
||||
Node<P> current = this.start;
|
||||
while(current != null) {
|
||||
if(s.contains(current.wert)) result.add(current.wert);
|
||||
current = current.next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public Set<P> union(Set<P> s) {
|
||||
Set<P> result = new Set<P>();
|
||||
Node<P> current = this.start;
|
||||
while(current != null) {
|
||||
current = current.next;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public class SetTest {
|
|||
set.isEmpty();
|
||||
|
||||
Set<Integer> I = set.intersection(set2);
|
||||
System.out.println("Größe " + set.size());
|
||||
System.out.println("Groeße " + set.size());
|
||||
set.Ausgabe();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue