public IndexingBounds1D(Index1D lowerBounds, Index1D dimensions)
        {
            Contracts.Requires.That(dimensions.IsAllPositiveOrZero());

            this.LowerBounds = lowerBounds;
            this.Dimensions  = dimensions;
            this.UpperBounds = lowerBounds + dimensions - new Index1D(1);
        }
Beispiel #2
0
        /// <summary>
        /// Generates a sequence of indices that are contained within a specified range.
        /// </summary>
        /// <param name="startIndex">The starting index.</param>
        /// <param name="dimensions">The dimensions of the range to generate.</param>
        /// <returns>An enumerable sequence of the indices inside of the specified range.</returns>
        public static IEnumerable <Index1D> Range(Index1D startIndex, Index1D dimensions)
        {
            Contracts.Requires.That(dimensions.IsAllPositiveOrZero());

            Index1D lastIndex = startIndex + dimensions;

            for (int iX = startIndex.X; iX < lastIndex.X; iX++)
            {
                yield return(new Index1D(iX));
            }
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Array1D{TValue}"/> class.
 /// </summary>
 /// <param name="dimensions">The dimensions of the array.</param>
 public Array1D(Index1D dimensions)
     : this(new T[dimensions.X])
 {
     Contracts.Requires.That(dimensions.IsAllPositiveOrZero());
 }
Beispiel #4
0
        /// <inheritdoc />
        public override bool IsIndexValid(Index1D index)
        {
            IReadOnlyIndexableContracts.IsIndexValid(this, index);

            return(index.IsAllPositiveOrZero());
        }