current.next.next = current.next = bullshit

master
SimonDHG 2023-12-13 11:02:08 +01:00
parent dc70fd4fb3
commit 69846239e2
4 changed files with 23 additions and 18 deletions

View File

@ -64,6 +64,7 @@ public class Set<T>
public boolean contains (T val){
Node<T> current = this.first;
while(current != null){
if(current.wert == val) return true;
current = current.next;
@ -74,10 +75,13 @@ public class Set<T>
public void remove(T val){
if(!this.contains(val))return;
Node<T> current = this.first;
if(this.first.wert == val){
this.first = this.first.next;
}
while(current.next.wert != val){
current = current.next;
}
current.next.next = current.next;
current.next = current.next.next;
this.length--;
}
@ -111,7 +115,7 @@ public class Set<T>
}
current = this.first;
while (current != null){
if (!tmp.contains(current.wert)) tmp.add(current.wert);
tmp.add(current.wert);
current = current.next;
}
return tmp;

View File

@ -1,7 +0,0 @@
public class __SHELL4 extends bluej.runtime.Shell {
public static void run() throws Throwable {
test.testset();
}}

View File

@ -11,24 +11,24 @@ dependency3.type=UsesDependency
dependency4.from=Stack
dependency4.to=Node
dependency4.type=UsesDependency
dependency5.from=test
dependency5.to=LinkedList
dependency5.from=Set
dependency5.to=Node
dependency5.type=UsesDependency
dependency6.from=test
dependency6.to=Node
dependency6.to=LinkedList
dependency6.type=UsesDependency
dependency7.from=test
dependency7.to=List
dependency7.to=Node
dependency7.type=UsesDependency
dependency8.from=test
dependency8.to=Set
dependency8.to=List
dependency8.type=UsesDependency
dependency9.from=Set
dependency9.to=Node
dependency9.from=test
dependency9.to=Set
dependency9.type=UsesDependency
editor.fx.0.height=919
editor.fx.0.width=2238
editor.fx.0.x=80
editor.fx.0.x=2
editor.fx.0.y=145
objectbench.height=100
objectbench.width=776
@ -36,7 +36,7 @@ package.divider.horizontal=0.6
package.divider.vertical=0.8003731343283582
package.editor.height=422
package.editor.width=661
package.editor.x=431
package.editor.x=303
package.editor.y=271
package.frame.height=600
package.frame.width=800

View File

@ -37,8 +37,16 @@ public class test
for (int i = 0; i<20 ; i++){
test.add(i);
}
Set<Integer> s = new Set<Integer>();
for (int i = 11; i < 16; i++){
s.add(i);
}
System.out.println(test);
test.remove(2);
System.out.println(test);
System.out.println(test.subset(s));
System.out.println(test.difference(s));
System.out.println(test.union(s));
System.out.println(test.intersection(s));
}
}