//Retourne une valeur en fonction de la clé entrée public U GetValue(T key) { MyHashTableObject <T, U> item = GetObject(key); if (item == null) { return(default(U)); } else { return(item.Value); } }
//Ajout d'une clé valeur public void Add(T key, U value) { int index = CustomGetHashCode(key); LinkedList <MyHashTableObject <T, U> > items = arr[index]; if (items == null) { items = new LinkedList <MyHashTableObject <T, U> >(); MyHashTableObject <T, U> item = new MyHashTableObject <T, U>(); item.Key = key; item.Value = value; items.AddLast(item); if (_size >= arr.Length * MAX_LOAD_FACTOR) { ExpandArrayCapacity(arr.Length + 1); } arr[index] = items; _size++; } else { foreach (var itemT in items) { if (itemT.Key.Equals(key)) { itemT.Value = value; return; } } MyHashTableObject <T, U> item = new MyHashTableObject <T, U>(); item.Key = key; item.Value = value; items.AddLast(item); } count++; }