public bool TryGetValue(TKey key, out TValue value) { var result = KeyedEntryCollection.Contains(key); value = result ? (TValue)KeyedEntryCollection[key].Value : default(TValue); return(result); }
protected int GetIndexAndEntryForKey(TKey key, out DictionaryEntry entry) { entry = new DictionaryEntry(); int index = -1; if (KeyedEntryCollection.Contains(key)) { entry = KeyedEntryCollection[key]; index = KeyedEntryCollection.IndexOf(entry); } return(index); }
protected virtual bool SetEntry(TKey key, TValue value) { var keyExists = KeyedEntryCollection.Contains(key); // if identical key/value pair already exists, nothing to do if (keyExists && value.Equals((TValue)KeyedEntryCollection[key].Value)) { return(false); } // otherwise, remove the existing entry if (keyExists) { KeyedEntryCollection.Remove(key); } // add the new entry KeyedEntryCollection.Add(new DictionaryEntry(key, value)); return(true); }
protected override bool SetEntry(TKey key, TValue value) { var keyExists = KeyedEntryCollection.Contains(key); // if identical key/value pair already exists, nothing to do if (keyExists && value.Equals((TValue)KeyedEntryCollection[key].Value)) { return(false); } // otherwise, remove the existing entry if (keyExists) { KeyedEntryCollection.Remove(key); } // add the new entry var entry = new DictionaryEntry(key, value); var index = GetInsertionIndexForEntry(entry); KeyedEntryCollection.Insert(index, entry); return(true); }
bool IDictionary <TKey, TValue> .ContainsKey(TKey key) { return(KeyedEntryCollection.Contains(key)); }
bool ICollection <KeyValuePair <TKey, TValue> > .Contains(KeyValuePair <TKey, TValue> kvp) { return(KeyedEntryCollection.Contains(kvp.Key)); }
bool IDictionary.Contains(object key) { return(KeyedEntryCollection.Contains((TKey)key)); }
public bool ContainsKey(TKey key) { return(KeyedEntryCollection.Contains(key)); }