X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP2%2FEntiers.java;h=b11f364ac9016a23dd947448f9e459dd6e753d06;hb=ae33f914c6b8f939fcef9589c0f14bec2ba37e6b;hp=a1e18b64911ed78cc45b4dcf8bcdc6ef348b9870;hpb=979297754a1c307ecbd003a745c4586f04f0c81a;p=TP_POO.git diff --git a/TP2/Entiers.java b/TP2/Entiers.java index a1e18b6..b11f364 100644 --- a/TP2/Entiers.java +++ b/TP2/Entiers.java @@ -1,4 +1,8 @@ +@ClassPreamble ( + author = "Jérôme Benoit", + date = "05/03/2009" +) class Entiers extends Structure { private int int_array[]; private int array_size; @@ -67,7 +71,7 @@ class Entiers extends Structure { return middle; else if (value > int_array[middle]) return binarySearch((middle + 1), last, value); - return binarySearch(first, (middle -1), value); + return binarySearch(first, (middle - 1), value); } public boolean supprimer(int value) { @@ -75,7 +79,6 @@ class Entiers extends Structure { System.out.println("Aucune valeur à supprimer"); return false; } - for (int i = 0; i < getCurrentSize(); i++) { if (int_array[i] == value) { // Deleting the element in the tab @@ -106,7 +109,11 @@ class Entiers extends Structure { } public void compacter(int nElements) { - + if (current_size - nElements > 0) { + // Remove the last nElements + current_size -= nElements; + } else { + current_size = 0; + } } - }