From: Jérôme Benoit Date: Thu, 8 Feb 2018 11:30:42 +0000 (+0100) Subject: Adress a FIXME on duplicated values insertion. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=471c182b1df38a97edaa66df75c749a8ad6e7e11;p=TP_POO.git Adress a FIXME on duplicated values insertion. Signed-off-by: Jérôme Benoit --- diff --git a/Entiers/Entiers.java b/Entiers/Entiers.java index 752546b..2159b95 100644 --- a/Entiers/Entiers.java +++ b/Entiers/Entiers.java @@ -31,7 +31,12 @@ class Entiers { System.out.println("Tableau plein"); return false; } - //FIXME: Avoid duplicated values + int pos = binarySearch(0, getCurrentSize(), value); + if (pos != -1) + { + System.out.println("Valeur à inserer déjà présente"); + return false; + } int i; for (i = getCurrentSize() - 1; (i >= 0 && int_array[i] > value); i--) { int_array[i + 1] = int_array[i];