Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 8
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;
                }
            }
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 11
0
 /// <inheritdoc />
 public new T this[Index3D index]
 {
     get { return(base[index]); }
     set { IIndexableContracts.IndexerSet(this, index); }
 }