/// <inheritdoc />
        public bool TrySetValue(TIndex index, TValue value)
        {
            IIndexableContracts.TrySetValue(this, index);

            this.dictionary[index] = value;
            return(true);
        }
Пример #2
0
        /// <inheritdoc />
        public bool TrySetValue(TIndex index, TValue value)
        {
            IIndexableContracts.TrySetValue(this, index);

            lock (this.indexableLock)
            {
                return(this.indexable.TrySetValue(index, value));
            }
        }
        /// <inheritdoc />
        public bool TrySetValue(TIndex index, TResult value)
        {
            IIndexableContracts.TrySetValue(this, index);

            if (this.indexable.IsIndexValid(index))
            {
                this.toSourceAction(this.indexable, index, value);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <inheritdoc />
        public bool TrySetValue(TIndex index, TValue value)
        {
            IIndexableContracts.TrySetValue(this, index);

            if (this.IsIndexValid(index))
            {
                // delegate to IDictionary implementation to ensure count is maintained properly
                this[index] = value;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        /// <inheritdoc />
        public override T this[Index2D index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                return(this.array[index - this.offset]);
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                this.array[index - this.offset] = value;
            }
        }
Пример #6
0
        /// <inheritdoc />
        public override T this[Index4D index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                return(this.array[index.X, index.Y, index.Z, index.W]);
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                this.array[index.X, index.Y, index.Z, index.W] = value;
            }
        }
        /// <inheritdoc />
        public TResult this[TIndex index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                return(this.toResultConverter(this.indexable, index, this.indexable[index]));
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                this.toSourceAction(this.indexable, index, value);
            }
        }
        /// <inheritdoc />
        public TValue this[TIndex index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                TValue result;
                return(this.dictionary.TryGetValue(index, out result) ? result : default(TValue));
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                this.dictionary[index] = value;
            }
        }
Пример #9
0
        /// <inheritdoc />
        public new TValue this[TIndex index]
        {
            get
            {
                return(base[index]);
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                if (this.setThrowsException)
                {
                    throw new NotSupportedException("Modifying constant indexable is not allowed.");
                }
            }
        }
        /// <inheritdoc />
        public override T this[Index3D index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                index = this.HandleArrayResizing(index);
                return(this.array[index.X, index.Y, index.Z]);
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                index = this.HandleArrayResizing(index);
                this.array[index.X, index.Y, index.Z] = value;
            }
        }
        /// <inheritdoc />
        public override T this[Index3D index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                Index3D subIndex;
                return(this.GetIndexable(index + this.originOffset, out subIndex)[subIndex]);
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                Index3D subIndex;
                this.GetIndexable(index + this.originOffset, out subIndex)[subIndex] = value;
            }
        }
Пример #12
0
        /// <inheritdoc />
        public TValue this[TIndex index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                lock (this.indexableLock)
                {
                    return(this.indexable[index]);
                }
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                lock (this.indexableLock)
                {
                    this.indexable[index] = value;
                }
            }
        }
Пример #13
0
        /// <inheritdoc />
        public override T this[Index3D index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                return(this.GetIndexable(index.X, index.Z)[new Index3D(
                                                               (index.X + this.singleArrayLengthX) % this.singleArrayLengthX,
                                                               index.Y,
                                                               (index.Z + this.singleArrayLengthZ) % this.singleArrayLengthZ)]);
            }

            set
            {
                IIndexableContracts.IndexerSet(this, index);

                this.GetIndexable(index.X, index.Z)[new Index3D(
                                                        (index.X + this.singleArrayLengthX) % this.singleArrayLengthX,
                                                        index.Y,
                                                        (index.Z + this.singleArrayLengthZ) % this.singleArrayLengthZ)] = value;
            }
        }
        /// <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);
            }
        }
Пример #15
0
 /// <inheritdoc />
 public new T this[Index3D index]
 {
     get { return(base[index]); }
     set { IIndexableContracts.IndexerSet(this, index); }
 }