/// <inheritdoc />
        public bool ContainsKey(TIndex key)
        {
            IDictionaryContracts.ContainsKey(key);

            TValue unused;

            return(this.TryGetValue(key, out unused));
        }
コード例 #2
0
        /// <inheritdoc />
        public override bool ContainsKey(TKey key)
        {
            IDictionaryContracts.ContainsKey(key);

            TValue unused;

            return(this.TryGetValue(key, out unused));
        }
コード例 #3
0
        /// <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++;
        }
コード例 #5
0
        /// <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);
        }
コード例 #7
0
        /// <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;
            }
        }
コード例 #8
0
        /// <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;
            }
        }
コード例 #9
0
        /// <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;
            }
        }
コード例 #10
0
        /// <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);
            }
        }
コード例 #13
0
        /// <inheritdoc />
        public bool ContainsKey(Type key)
        {
            IDictionaryContracts.ContainsKey(key);

            return(this.values.ContainsKey(key));
        }
コード例 #14
0
        /// <inheritdoc />
        public bool Remove(TIndex key)
        {
            IDictionaryContracts.Remove(this, key);

            return(this.dictionary.Remove(key));
        }
コード例 #15
0
        /// <inheritdoc />
        public bool ContainsKey(TIndex key)
        {
            IDictionaryContracts.ContainsKey(key);

            return(this.dictionary.ContainsKey(key));
        }
コード例 #16
0
        /// <inheritdoc />
        public void Add(TIndex key, TValue value)
        {
            IDictionaryContracts.Add(this, key);

            this.dictionary.Add(key, value);
        }
コード例 #17
0
        /// <inheritdoc />
        bool IDictionary <TIndex, TValue> .TryGetValue(TIndex index, out TValue value)
        {
            IDictionaryContracts.TryGetValue(index);

            return(this.dictionary.TryGetValue(index, out value));
        }
コード例 #18
0
        /// <inheritdoc />
        public virtual void Add(TKey key, TValue value)
        {
            IDictionaryContracts.Add(this, key);

            this.Dictionary.Add(key, value);
        }
コード例 #19
0
        /// <inheritdoc />
        public virtual bool Remove(TKey key)
        {
            IDictionaryContracts.Remove(this, key);

            return(this.Dictionary.Remove(key));
        }
コード例 #20
0
        /// <inheritdoc />
        public virtual bool TryGetValue(TKey key, out TValue value)
        {
            IDictionaryContracts.TryGetValue(key);

            return(this.Dictionary.TryGetValue(key, out value));
        }
コード例 #21
0
        /// <inheritdoc />
        public bool TryGetValue(Type key, out TBase value)
        {
            IDictionaryContracts.TryGetValue(key);

            return(this.values.TryGetValue(key, out value));
        }
コード例 #22
0
        /// <inheritdoc />
        public virtual bool ContainsKey(TKey key)
        {
            IDictionaryContracts.ContainsKey(key);

            return(this.Dictionary.ContainsKey(key));
        }