forked from pabulaner/vivi
Starting LinkedList
This commit is contained in:
parent
9aa1ec26db
commit
5a7a6e8a56
73
list/src/main/java/de/vivi/list/LinkedByteList.java
Normal file
73
list/src/main/java/de/vivi/list/LinkedByteList.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -9,10 +9,11 @@ public class Main {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ByteList array = new ArrayByteList();
|
ByteList array = new ArrayByteList();
|
||||||
// ByteList linked = new LinkedByteList();
|
ByteList linked = new LinkedByteList();
|
||||||
// ByteList combined = new CombinedByteList(16);
|
// ByteList combined = new CombinedByteList(16);
|
||||||
testListVivi(array);
|
// testListVivi(array);
|
||||||
testSortVivi(array);
|
testListVivi(linked);
|
||||||
|
// testSortVivi(array);
|
||||||
//testList(array);
|
//testList(array);
|
||||||
// testList(linked);
|
// testList(linked);
|
||||||
// testList(combined);
|
// testList(combined);
|
||||||
@ -27,14 +28,14 @@ public class Main {
|
|||||||
list.add((byte) 5);
|
list.add((byte) 5);
|
||||||
list.add((byte) -86);
|
list.add((byte) -86);
|
||||||
list.add((byte) 3);
|
list.add((byte) 3);
|
||||||
list.add((byte) 5);
|
// list.add((byte) 5);
|
||||||
list.add((byte) -100);
|
// list.add((byte) -100);
|
||||||
|
|
||||||
// System.out.println(list);
|
// System.out.println(list);
|
||||||
|
|
||||||
list.add(3, (byte) 99);
|
// list.add(3, (byte) 99);
|
||||||
// System.out.println(list);
|
//// System.out.println(list);
|
||||||
list.add(2, (byte) -40);
|
// list.add(2, (byte) -40);
|
||||||
// System.out.println(list);
|
// System.out.println(list);
|
||||||
|
|
||||||
// list.remove(2);
|
// list.remove(2);
|
||||||
@ -42,7 +43,7 @@ public class Main {
|
|||||||
// list.remove(3);
|
// list.remove(3);
|
||||||
// System.out.println(list);
|
// System.out.println(list);
|
||||||
|
|
||||||
list.set(1, (byte) 43);
|
// list.set(1, (byte) 43);
|
||||||
System.out.println(list);
|
System.out.println(list);
|
||||||
// list.set(0, (byte) 8);
|
// list.set(0, (byte) 8);
|
||||||
//// System.out.println(list);
|
//// System.out.println(list);
|
||||||
|
|||||||
14
list/src/main/java/de/vivi/list/NodeLinked.java
Normal file
14
list/src/main/java/de/vivi/list/NodeLinked.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user