abc
commit
0660cbd007
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/bin/
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Abstrakte_Sachen</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -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
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
public class Listikus<T> {
|
||||
|
||||
private Node<T> 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<T> 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<T>(wert);
|
||||
}
|
||||
else {
|
||||
Node<T> current = this.start;
|
||||
while(current.next != null) {
|
||||
current = current.next;
|
||||
}
|
||||
|
||||
current.next = new Node<T>(wert);
|
||||
}
|
||||
}
|
||||
|
||||
public Node<T> getStart() {
|
||||
return this.start;
|
||||
}
|
||||
|
||||
public void addBetween(int n, T val) {
|
||||
g++;
|
||||
if(n < g) {
|
||||
Node<T> neu = new Node<T>(val);
|
||||
Node<T> 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<T> current = this.start;
|
||||
while(current.wert != val) {
|
||||
if(current.next == null) {
|
||||
return false;
|
||||
}
|
||||
current = current.next;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public T remove(int n) {
|
||||
Node<T> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
public class Node<T> {
|
||||
|
||||
public T wert;
|
||||
|
||||
public Node<T> next;
|
||||
|
||||
public Node(T z) {
|
||||
wert = z;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
public class Queue<T>{
|
||||
|
||||
private Node<T> 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<T>(val);
|
||||
}
|
||||
else {
|
||||
Node<T> current = this.start;
|
||||
while(current.next != null) {
|
||||
current = current.next;
|
||||
}
|
||||
|
||||
current.next = new Node<T>(val);
|
||||
}
|
||||
}
|
||||
|
||||
public T dequeue() {
|
||||
|
||||
Node<T> current = this.start;
|
||||
Node<T> 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<T> getStart() {
|
||||
return this.start;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
public class Stack<T> {
|
||||
private Node<T> 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<T> neu = new Node<T>(val);
|
||||
Node<T> starter = new Node<T>(val);
|
||||
if(isEmpty() == true) {
|
||||
this.start = new Node<T>(val);
|
||||
}
|
||||
else {
|
||||
Node<T> current = neu;
|
||||
starter = this.start;
|
||||
start = neu;
|
||||
current = neu;
|
||||
current.next = starter;
|
||||
current = current.next;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public T pop() {
|
||||
|
||||
Node<T> current = this.start;
|
||||
Node<T> 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<T> getStart() {
|
||||
return this.start;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
public class Start{
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("Liste:");
|
||||
Listikus<Integer> L = new Listikus<Integer>();
|
||||
L.add(1);
|
||||
L.add(2);
|
||||
L.add(3);
|
||||
L.add(4);
|
||||
L.add(5);
|
||||
Node<Integer> current = L.getStart();
|
||||
while(current != null) {
|
||||
|
||||
System.out.println(current.wert);
|
||||
current = current.next;
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Queue:");
|
||||
Queue<Integer> Q = new Queue<Integer>();
|
||||
Q.enqueue(1);
|
||||
Q.enqueue(2);
|
||||
Q.enqueue(3);
|
||||
Q.enqueue(4);
|
||||
Q.enqueue(5);
|
||||
Node<Integer> 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<Integer> S = new Stack<Integer>();
|
||||
S.push(1);
|
||||
S.push(2);
|
||||
S.push(3);
|
||||
S.push(4);
|
||||
S.push(5);
|
||||
Node<Integer> curren = S.getStart();
|
||||
while(curren != null) {
|
||||
|
||||
System.out.println(curren.wert);
|
||||
curren = curren.next;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue