コード例 #1
0
        /// <inheritdoc />
        public bool TryGetValue(TIndex index, out TValue value)
        {
            IReadOnlyIndexableContracts.TryGetValue(this, index);

            lock (this.indexableLock)
            {
                return(this.indexable.TryGetValue(index, out value));
            }
        }
コード例 #2
0
        /// <inheritdoc />
        public bool IsIndexValid(TIndex index)
        {
            IReadOnlyIndexableContracts.IsIndexValid(this, index);

            lock (this.indexableLock)
            {
                return(this.indexable.IsIndexValid(index));
            }
        }
コード例 #3
0
        /// <inheritdoc />
        public TValue this[TIndex index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                return(this.ConstantValue);
            }
        }
コード例 #4
0
        /// <inheritdoc />
        public T this[Index3D index]
        {
            get
            {
                IReadOnlyIndexableContracts.IndexerGet(this, index);

                Index3D subIndex;
                return(this.GetIndexable(index + this.originOffset, out subIndex)[subIndex]);
            }
        }
コード例 #5
0
        /// <inheritdoc />
        public bool TryGetValue(TIndex index, out TValue value)
        {
            IReadOnlyIndexableContracts.TryGetValue(this, index);

            if (!this.dictionary.TryGetValue(index, out value))
            {
                value = default(TValue);
            }

            return(true);
        }
コード例 #6
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;
            }
        }
        /// <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);
            }
        }
コード例 #8
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 bool TryGetValue(TIndex index, out TResult value)
        {
            IReadOnlyIndexableContracts.TryGetValue(this, index);

            TSource sourceValue;

            if (this.indexable.TryGetValue(index, out sourceValue))
            {
                value = this.toResultConverter(this.indexable, index, sourceValue);
                return(true);
            }
            else
            {
                value = default(TResult);
                return(false);
            }
        }
コード例 #10
0
        /// <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;
            }
        }
コード例 #11
0
        /// <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 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);
        }
コード例 #13
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;
                }
            }
        }
コード例 #14
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);
            }
        }
コード例 #16
0
        /// <inheritdoc />
        public virtual bool IsIndexValid(Index2D index)
        {
            IReadOnlyIndexableContracts.IsIndexValid(this, index);

            return(true);
        }
コード例 #17
0
        /// <inheritdoc />
        public bool IsIndexValid(Index3D index)
        {
            IReadOnlyIndexableContracts.IsIndexValid(this, index);

            return(this.IsIndexInBounds(index));
        }
コード例 #18
0
        /// <inheritdoc />
        public override bool IsIndexValid(Index4D index)
        {
            IReadOnlyIndexableContracts.IsIndexValid(this, index);

            return(index.IsAllPositiveOrZero());
        }
コード例 #19
0
        /// <inheritdoc />
        public bool IsIndexValid(TIndex index)
        {
            IReadOnlyIndexableContracts.IsIndexValid(this, index);

            return(true);
        }