/// <inheritdoc /> public bool ContainsKey(TIndex key) { IDictionaryContracts.ContainsKey(key); TValue unused; return(this.TryGetValue(key, out unused)); }
/// <inheritdoc /> public override bool ContainsKey(TKey key) { IDictionaryContracts.ContainsKey(key); TValue unused; return(this.TryGetValue(key, out unused)); }
/// <inheritdoc /> public override void Add(TKey key, TValue value) { IDictionaryContracts.Add(this, key); if (this.addValue(KeyValuePair.New(key, value))) { this.Dictionary.Add(key, value); } }
/// <inheritdoc /> public void Add(TIndex key, TValue value) { IDictionaryContracts.Add(this, key); // this method's contracts checks that the dictionary doesn't already contain this key // thus if it passes the contract a new value will always be added this.indexable[key] = TryValue.New(value); this.count++; }
/// <inheritdoc /> public override bool TryGetValue(TKey key, out TValue value) { IDictionaryContracts.TryGetValue(key); if (!this.Dictionary.TryGetValue(key, out value)) { value = this.producer(key); this.Dictionary[key] = value; } return(true); }
/// <inheritdoc /> public bool Remove(TIndex key) { IDictionaryContracts.Remove(this, key); if (!this.ContainsKey(key)) { return(false); } this.indexable[key] = TryValue.None <TValue>(); this.count--; return(true); }
/// <inheritdoc /> TValue IDictionary <TIndex, TValue> .this[TIndex index] { get { IDictionaryContracts.IndexerGet(this, index); return(this.dictionary[index]); } set { IDictionaryContracts.IndexerSet(this, index); this.dictionary[index] = value; } }
/// <inheritdoc /> public virtual TValue this[TKey key] { get { IDictionaryContracts.IndexerGet(this, key); return(this.Dictionary[key]); } set { IDictionaryContracts.IndexerSet(this, key); this.Dictionary[key] = value; } }
/// <inheritdoc /> public override TValue this[TKey key] { get { IDictionaryContracts.IndexerGet(this, key); TValue result; this.TryGetValue(key, out result); return(result); } set { IDictionaryContracts.IndexerSet(this, key); this.Dictionary[key] = value; } }
/// <inheritdoc /> public override TValue this[TKey key] { get { IDictionaryContracts.IndexerGet(this, key); return(this.Dictionary[key]); } set { IDictionaryContracts.IndexerSet(this, key); if (this.addValue(KeyValuePair.New(key, value))) { this.Dictionary[key] = value; } } }
/// <inheritdoc /> public bool TryGetValue(TIndex key, out TValue value) { IDictionaryContracts.TryGetValue(key); IReadOnlyIndexableContracts.TryGetValue(this, key); TryValue <TValue> result; if (this.indexable.TryGetValue(key, out result)) { if (result.HasValue) { value = result.Value; return(true); } } // either the try get failed or the result had no value. Failure either way value = default(TValue); return(false); }
/// <inheritdoc /> public TValue this[TIndex index] { // this method's contracts will check that the dictionary contains the key first get { IDictionaryContracts.IndexerGet(this, index); IReadOnlyIndexableContracts.IndexerGet(this, index); return(this.indexable[index].Value); } set { IDictionaryContracts.IndexerSet(this, index); IIndexableContracts.IndexerSet(this, index); if (!this.indexable[index].HasValue) { this.count++; } this.indexable[index] = TryValue.New(value); } }
/// <inheritdoc /> public bool ContainsKey(Type key) { IDictionaryContracts.ContainsKey(key); return(this.values.ContainsKey(key)); }
/// <inheritdoc /> public bool Remove(TIndex key) { IDictionaryContracts.Remove(this, key); return(this.dictionary.Remove(key)); }
/// <inheritdoc /> public bool ContainsKey(TIndex key) { IDictionaryContracts.ContainsKey(key); return(this.dictionary.ContainsKey(key)); }
/// <inheritdoc /> public void Add(TIndex key, TValue value) { IDictionaryContracts.Add(this, key); this.dictionary.Add(key, value); }
/// <inheritdoc /> bool IDictionary <TIndex, TValue> .TryGetValue(TIndex index, out TValue value) { IDictionaryContracts.TryGetValue(index); return(this.dictionary.TryGetValue(index, out value)); }
/// <inheritdoc /> public virtual void Add(TKey key, TValue value) { IDictionaryContracts.Add(this, key); this.Dictionary.Add(key, value); }
/// <inheritdoc /> public virtual bool Remove(TKey key) { IDictionaryContracts.Remove(this, key); return(this.Dictionary.Remove(key)); }
/// <inheritdoc /> public virtual bool TryGetValue(TKey key, out TValue value) { IDictionaryContracts.TryGetValue(key); return(this.Dictionary.TryGetValue(key, out value)); }
/// <inheritdoc /> public bool TryGetValue(Type key, out TBase value) { IDictionaryContracts.TryGetValue(key); return(this.values.TryGetValue(key, out value)); }
/// <inheritdoc /> public virtual bool ContainsKey(TKey key) { IDictionaryContracts.ContainsKey(key); return(this.Dictionary.ContainsKey(key)); }