From b48ca56a1f3dd80b09d1840121de5e694a989fb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 7 Feb 2018 12:19:08 +0100 Subject: [PATCH] Properly rename heap -> stack. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- Piles/Pile.java | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/Piles/Pile.java b/Piles/Pile.java index e7d4b4d..b82dd7e 100644 --- a/Piles/Pile.java +++ b/Piles/Pile.java @@ -2,7 +2,7 @@ class Pile { private int int_array[]; private int array_size; - private int heap_head_index; + private int stack_head_index; private void setSize(int size) { array_size = size; @@ -13,11 +13,11 @@ class Pile { } private void setHeadIndex(int index) { - heap_head_index = index; + stack_head_index = index; } private int getHeadIndex() { - return heap_head_index; + return stack_head_index; } Pile(int size) { @@ -28,8 +28,8 @@ class Pile { public void empiler(int value) { if (!plein()) { - int_array[heap_head_index] = value; - heap_head_index++; + int_array[stack_head_index] = value; + stack_head_index++; } else { System.out.println("La pile est pleine"); } @@ -37,8 +37,8 @@ class Pile { public int depiler() { if (!vide()) { - heap_head_index--; - return int_array[heap_head_index]; + stack_head_index--; + return int_array[stack_head_index]; } else { return -1; } @@ -59,30 +59,30 @@ class Pile { } public static void main(String[] args) { - Pile heap = new Pile(5); - - heap.empiler(3); - heap.empiler(5); - heap.empiler(4); - heap.empiler(7); - heap.empiler(8); - - heap.afficher(); - - System.out.println("Heap index " + heap.getHeadIndex()); - System.out.println("Heap head value " + heap.depiler()); - System.out.println("Heap index " + heap.getHeadIndex()); - System.out.println("Heap head value " + heap.depiler()); - System.out.println("Heap index " + heap.getHeadIndex()); - System.out.println("Heap head value " + heap.depiler()); - System.out.println("Heap index " + heap.getHeadIndex()); - System.out.println("Heap head value " + heap.depiler()); - System.out.println("Heap index " + heap.getHeadIndex()); - System.out.println("Heap head value " + heap.depiler()); - System.out.println("Heap index " + heap.getHeadIndex()); - System.out.println("Heap head value " + heap.depiler()); - System.out.println("Heap index " + heap.getHeadIndex()); - - heap.afficher(); + Pile stack = new Pile(5); + + stack.empiler(3); + stack.empiler(5); + stack.empiler(4); + stack.empiler(7); + stack.empiler(8); + + stack.afficher(); + + System.out.println("stack index " + stack.getHeadIndex()); + System.out.println("stack head value " + stack.depiler()); + System.out.println("stack index " + stack.getHeadIndex()); + System.out.println("stack head value " + stack.depiler()); + System.out.println("stack index " + stack.getHeadIndex()); + System.out.println("stack head value " + stack.depiler()); + System.out.println("stack index " + stack.getHeadIndex()); + System.out.println("stack head value " + stack.depiler()); + System.out.println("stack index " + stack.getHeadIndex()); + System.out.println("stack head value " + stack.depiler()); + System.out.println("stack index " + stack.getHeadIndex()); + System.out.println("stack head value " + stack.depiler()); + System.out.println("stack index " + stack.getHeadIndex()); + + stack.afficher(); } } -- 2.34.1