X-Git-Url: https://git.piment-noir.org/?p=TP_POO.git;a=blobdiff_plain;f=Listes%2FListe.java;fp=Listes%2FListe.java;h=8256bcb89de74d1aa52f5a1ef4f90b446640bc44;hp=ca2d42d96920de9eea6647d88bf3eba71f80158d;hb=f00e7dee9b1470315e6365e3d17bf8bbc9aab89e;hpb=ae33f914c6b8f939fcef9589c0f14bec2ba37e6b diff --git a/Listes/Liste.java b/Listes/Liste.java index ca2d42d..8256bcb 100644 --- a/Listes/Liste.java +++ b/Listes/Liste.java @@ -1,40 +1,7 @@ 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 headNode; private int list_counter; Liste() { @@ -55,25 +22,25 @@ public class Liste { list_counter = size; } - private void setHeadNode(IntNode node) { + private void setHeadNode(Node node) { headNode = node; } - private IntNode getHeadNode() { + private Node getHeadNode() { return headNode; } public void inserer(int value) { boolean found = false; if (isEmpty()) { - headNode = new IntNode(value); + headNode = new Node(value); list_counter++; return; } else if (value == headNode.getData()) { found = true; return; } else { - IntNode nodeCursorNext = headNode.getNext(); + Node nodeCursorNext = headNode.getNext(); while (nodeCursorNext != null) { if (value == nodeCursorNext.getData()) { found = true; @@ -83,7 +50,7 @@ public class Liste { } } if (!found) { - headNode = new IntNode(value, headNode); + headNode = new Node(value, headNode); list_counter++; } } @@ -98,8 +65,8 @@ public class Liste { deleted = true; list_counter--; } else { - IntNode nodeCursor = headNode; - IntNode nodeCursorNext = headNode.getNext(); + Node nodeCursor = headNode; + Node nodeCursorNext = headNode.getNext(); while (nodeCursorNext != null) { if (value == nodeCursorNext.getData()) { nodeCursor.setNext(nodeCursorNext.getNext()); @@ -124,7 +91,7 @@ public class Liste { } else if (headNode.getNext() == null) { System.out.println("element " + i + " : " + headNode.getData()); } else { - IntNode nodeCursorNext = headNode.getNext(); + Node nodeCursorNext = headNode.getNext(); System.out.println("element " + i + " : " + headNode.getData()); i++; while (nodeCursorNext != null) {