commit 0660cbd007edd4fd391eebb1e940ee936abe2639 Author: buschlfl Date: Mon Feb 21 12:35:43 2022 +0100 abc diff --git a/Abstrakte_Sachen/.classpath b/Abstrakte_Sachen/.classpath new file mode 100644 index 0000000..d54800d --- /dev/null +++ b/Abstrakte_Sachen/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Abstrakte_Sachen/.gitignore b/Abstrakte_Sachen/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Abstrakte_Sachen/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Abstrakte_Sachen/.project b/Abstrakte_Sachen/.project new file mode 100644 index 0000000..15807ce --- /dev/null +++ b/Abstrakte_Sachen/.project @@ -0,0 +1,17 @@ + + + Abstrakte_Sachen + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Abstrakte_Sachen/.settings/org.eclipse.jdt.core.prefs b/Abstrakte_Sachen/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f2525a8 --- /dev/null +++ b/Abstrakte_Sachen/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/Abstrakte_Sachen/src/Listikus.java b/Abstrakte_Sachen/src/Listikus.java new file mode 100644 index 0000000..5ed6f1a --- /dev/null +++ b/Abstrakte_Sachen/src/Listikus.java @@ -0,0 +1,100 @@ + +public class Listikus { + + private Node start; + private int g; + + public Listikus() { + this.start = null; + } + + public boolean isEmpty(){ + if(this.start == null) { + return true; + } + else { + return false; + } + } + + public int size(int g){ + return g; + } + + public T get( int n) { + Node current = this.start; + int z = 0; + if(n < g) { + while(z!=n) { + current = current.next; + z++; + } + return current.wert; + } + return null; + } + + public void add(T wert) { + this.g++; + + if(isEmpty() == true) { + this.start = new Node(wert); + } + else { + Node current = this.start; + while(current.next != null) { + current = current.next; + } + + current.next = new Node(wert); + } + } + + public Node getStart() { + return this.start; + } + + public void addBetween(int n, T val) { + g++; + if(n < g) { + Node neu = new Node(val); + Node current = this.start; + int z = 0; + while(z!=n-1) { + current = current.next; + z++; + } + neu.next = current.next; + current.next = neu; + } + else { + add(val); + } + } + + public boolean contains( T val) { + Node current = this.start; + while(current.wert != val) { + if(current.next == null) { + return false; + } + current = current.next; + } + return true; + } + + public T remove(int n) { + Node current = this.start; + int z = 0; + while(z!=n - 1) { + current = current.next; + z++; + } + T cur = current.next.wert; + current.next = current.next.next; + this.g--; + return cur; + } + + +} diff --git a/Abstrakte_Sachen/src/Node.java b/Abstrakte_Sachen/src/Node.java new file mode 100644 index 0000000..2cf30d2 --- /dev/null +++ b/Abstrakte_Sachen/src/Node.java @@ -0,0 +1,11 @@ + +public class Node { + + public T wert; + + public Node next; + + public Node(T z) { + wert = z; + } +} diff --git a/Abstrakte_Sachen/src/Queue.java b/Abstrakte_Sachen/src/Queue.java new file mode 100644 index 0000000..90eaf8f --- /dev/null +++ b/Abstrakte_Sachen/src/Queue.java @@ -0,0 +1,65 @@ + +public class Queue{ + + private Node start; + public int g; + + public Queue() { + this.start = null; + } + + public boolean isEmpty(){ + if(this.start == null) { + return true; + } + else { + return false; + } + } + + public void enqueue(T val) { + if(isEmpty() == true) { + this.start = new Node(val); + } + else { + Node current = this.start; + while(current.next != null) { + current = current.next; + } + + current.next = new Node(val); + } + } + + public T dequeue() { + + Node current = this.start; + Node starter = current.next; + if(isEmpty() == true) { + return null; + } + else { + T val = this.start.wert; + this.start = starter; + return val; + + } + } + + public T front() { + if(isEmpty() == true) { + return null; + } + else { + return this.start.wert; + } + } + + public Node getStart() { + return this.start; + } + + + + +} diff --git a/Abstrakte_Sachen/src/Stack.java b/Abstrakte_Sachen/src/Stack.java new file mode 100644 index 0000000..20ee4e4 --- /dev/null +++ b/Abstrakte_Sachen/src/Stack.java @@ -0,0 +1,67 @@ + +public class Stack { + private Node start; + public int g; + + public Stack() { + this.start = null; + } + + public boolean isEmpty(){ + if(this.start == null) { + return true; + } + else { + return false; + } + } + + public void push(T val) { + Node neu = new Node(val); + Node starter = new Node(val); + if(isEmpty() == true) { + this.start = new Node(val); + } + else { + Node current = neu; + starter = this.start; + start = neu; + current = neu; + current.next = starter; + current = current.next; + + + } + } + + public T pop() { + + Node current = this.start; + Node starter = current.next; + if(isEmpty() == true) { + return null; + } + else { + T val = this.start.wert; + this.start = starter; + return val; + } + } + + public T top() { + if(isEmpty() == true) { + return null; + } + else { + return this.start.wert; + } + } + + public Node getStart() { + return this.start; + } + + + + +} diff --git a/Abstrakte_Sachen/src/Start.java b/Abstrakte_Sachen/src/Start.java new file mode 100644 index 0000000..729c95c --- /dev/null +++ b/Abstrakte_Sachen/src/Start.java @@ -0,0 +1,60 @@ +public class Start{ + + public static void main(String[] args) { + + System.out.println("Liste:"); + Listikus L = new Listikus(); + L.add(1); + L.add(2); + L.add(3); + L.add(4); + L.add(5); + Node current = L.getStart(); + while(current != null) { + + System.out.println(current.wert); + current = current.next; + } + + System.out.println(); + System.out.println("Queue:"); + Queue Q = new Queue(); + Q.enqueue(1); + Q.enqueue(2); + Q.enqueue(3); + Q.enqueue(4); + Q.enqueue(5); + Node cur = Q.getStart(); + while(cur != null) { + + System.out.println(cur.wert); + cur = cur.next; + } + System.out.println(); + System.out.println(Q.dequeue()); + System.out.println(); + cur = Q.getStart(); + while(cur != null) { + + System.out.println(cur.wert); + cur = cur.next; + } + System.out.println(); + System.out.println(Q.front()); + + System.out.println(); + System.out.println("Stack:"); + Stack S = new Stack(); + S.push(1); + S.push(2); + S.push(3); + S.push(4); + S.push(5); + Node curren = S.getStart(); + while(curren != null) { + + System.out.println(curren.wert); + curren = curren.next; + } + } +}