1
0
forked from pabulaner/vivi

Starting LinkedList

This commit is contained in:
happymeal2024 2025-04-09 18:08:26 +02:00
parent 9aa1ec26db
commit 5a7a6e8a56
3 changed files with 97 additions and 9 deletions

View File

@ -0,0 +1,73 @@
package de.vivi.list;
import java.util.Iterator;
public class LinkedByteList implements ByteList {
public NodeLinked head;
public NodeLinked tail;
public LinkedByteList() {
this.head = null;
this.tail = null;
}
@Override
public void add(byte value) {
NodeLinked new_Node = new NodeLinked(value);
if (head == null) {
head = new_Node;
tail = new_Node;
} else {
tail.next = new_Node;
tail = new_Node;
}
}
@Override
public void add(int index, byte value) {
}
@Override
public void remove(int index) {
}
@Override
public void set(int index, byte value) {
}
@Override
public byte get(int index) {
return 0;
}
@Override
public int size() {
return 0;
}
@Override
public boolean contains(int value) {
return false;
}
@Override
public ArrayByteList copy() {
return null;
}
@Override
public void clear() {
}
@Override
public Iterator<Byte> iterator() {
return null;
}
}

View File

@ -9,10 +9,11 @@ public class Main {
public static void main(String[] args) {
ByteList array = new ArrayByteList();
// ByteList linked = new LinkedByteList();
ByteList linked = new LinkedByteList();
// ByteList combined = new CombinedByteList(16);
testListVivi(array);
testSortVivi(array);
// testListVivi(array);
testListVivi(linked);
// testSortVivi(array);
//testList(array);
// testList(linked);
// testList(combined);
@ -27,14 +28,14 @@ public class Main {
list.add((byte) 5);
list.add((byte) -86);
list.add((byte) 3);
list.add((byte) 5);
list.add((byte) -100);
// list.add((byte) 5);
// list.add((byte) -100);
// System.out.println(list);
list.add(3, (byte) 99);
// System.out.println(list);
list.add(2, (byte) -40);
// list.add(3, (byte) 99);
//// System.out.println(list);
// list.add(2, (byte) -40);
// System.out.println(list);
// list.remove(2);
@ -42,7 +43,7 @@ public class Main {
// list.remove(3);
// System.out.println(list);
list.set(1, (byte) 43);
// list.set(1, (byte) 43);
System.out.println(list);
// list.set(0, (byte) 8);
//// System.out.println(list);

View File

@ -0,0 +1,14 @@
package de.vivi.list;
public class NodeLinked {
byte data;
NodeLinked next;
NodeLinked prev;
public NodeLinked(byte data) {
this.data = data;
this.next = null;
this.prev = null;
}
}