public class Liste {
-
- private class IntNode {
- private int data;
- private IntNode next;
-
- IntNode(int value) {
- setData(value);
- setNext(null);
- }
-
- IntNode(int value, IntNode nextNode) {
- setData(value);
- setNext(nextNode);
- }
-
- private int getData() {
- return data;
- }
-
- private void setData(int value) {
- data = value;
- }
-
- private IntNode getNext() {
- return next;
- }
-
- private void setNext(IntNode nextNode) {
- next = nextNode;
- }
-
- }
-
- private IntNode headNode;
+ private Node<Integer> headNode;
private int list_counter;
Liste() {
list_counter = size;
}
- private void setHeadNode(IntNode node) {
+ private void setHeadNode(Node<Integer> node) {
headNode = node;
}
- private IntNode getHeadNode() {
+ private Node<Integer> getHeadNode() {
return headNode;
}
public void inserer(int value) {
boolean found = false;
if (isEmpty()) {
- headNode = new IntNode(value);
+ headNode = new Node<Integer>(value);
list_counter++;
return;
} else if (value == headNode.getData()) {
found = true;
return;
} else {
- IntNode nodeCursorNext = headNode.getNext();
+ Node<Integer> nodeCursorNext = headNode.getNext();
while (nodeCursorNext != null) {
if (value == nodeCursorNext.getData()) {
found = true;
}
}
if (!found) {
- headNode = new IntNode(value, headNode);
+ headNode = new Node<Integer>(value, headNode);
list_counter++;
}
}
deleted = true;
list_counter--;
} else {
- IntNode nodeCursor = headNode;
- IntNode nodeCursorNext = headNode.getNext();
+ Node<Integer> nodeCursor = headNode;
+ Node<Integer> nodeCursorNext = headNode.getNext();
while (nodeCursorNext != null) {
if (value == nodeCursorNext.getData()) {
nodeCursor.setNext(nodeCursorNext.getNext());
} else if (headNode.getNext() == null) {
System.out.println("element " + i + " : " + headNode.getData());
} else {
- IntNode nodeCursorNext = headNode.getNext();
+ Node<Integer> nodeCursorNext = headNode.getNext();
System.out.println("element " + i + " : " + headNode.getData());
i++;
while (nodeCursorNext != null) {