This commit is contained in:
SOLAR D
2026-10-21 11:39:51 +02:00
parent 675605e80f
commit e44ffa16ce
+13
View File
@@ -148,6 +148,19 @@ long meilleure_periode(const long *totaux, int nb_jours, int *debut, int *fin)
/* F6 : retrouve une transaction à partir de son id */
const Transaction *rechercher_par_id(const Transaction *t, int n, int id)
{
static const Transaction *index[NB_TRANSACTIONS];
static const Transaction *transactions_indexees;
static int taille_indexee;
if (n <= NB_TRANSACTIONS && (t != transactions_indexees || n != taille_indexee)) {
for (int i = 0; i < n; i++)
index[t[i].id] = &t[i];
transactions_indexees = t;
taille_indexee = n;
}
if (n <= NB_TRANSACTIONS && id >= 0 && id < n && t == transactions_indexees)
return index[id];
for (int i = 0; i < n; i++)
if (t[i].id == id)
return &t[i];