public V Set(K1 key1, K2 key2, V value) { if (!(this.size >= this.threshold)) { List <DoubleKeyValuePair <K1, K2, V> > chain = FindChain(key1, key2, true); for (int i = 0; i < chain.Count; i++) { DoubleKeyValuePair <K1, K2, V> entry = chain[i]; if (entry.Key1.Equals(key1) && entry.Key2.Equals(key2)) { DoubleKeyValuePair <K1, K2, V> newEntry = new DoubleKeyValuePair <K1, K2, V>(key1, key2, value); chain[i] = newEntry; return(entry.Value); } } chain.Add(new DoubleKeyValuePair <K1, K2, V>(key1, key2, value)); this.size++; return(default(V)); } else { Console.WriteLine("Dictionary is full"); return(default(V)); } }
public bool Remove(K1 key1, K2 key2) { List <DoubleKeyValuePair <K1, K2, V> > chain = FindChain(key1, key2, false); for (int i = 0; i < chain.Count; i++) { DoubleKeyValuePair <K1, K2, V> entry = chain[i]; if (entry.Key1.Equals(key1) && entry.Key2.Equals(key2)) { chain.RemoveAt(i); this.size--; return(true); } } return(false); }