def cree(): return { 'taille':0, 'paquets': [[] for _ in range(32)] } def contient(s, x): p = x % len(s['paquets']) return x in s['paquets'][p] def ajoute(s, x): if contient(s, x): return s['taille'] += 1 if s['taille'] > len(s['paquets']): _etend(s) _ajoute_aux(s['paquets'], x) def _ajoute_aux(t, x): p = x % len(t) t[p].append(x) def _etend(s): tmp = [[] for _ in range(2 * len(s['paquets']))] for x in enumere(s): _ajoute_aux(tmp, x) s['paquets'] = tmp def enumere(s): tab = [] for paquet in s['paquets']: tab.extend(paquet) return tab