Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Incapsulation.Weights
- {
- public class Indexer
- {
- private double[] array;
- public readonly int Position;
- public double[] NewArray;
- public int Length
- {
- get
- {
- return NewArray.Length;
- }
- }
- public double this[int index]
- {
- get
- {
- if (index < 0 || index > NewArray.Length)
- throw new IndexOutOfRangeException();
- return NewArray[index];
- }
- set
- {
- if (index >= Length)
- throw new IndexOutOfRangeException();
- NewArray[index] = value;
- array[index + Position] = value;
- }
- }
- public Indexer(double[] array, int position, int count)
- {
- Position = position;
- if (position < 0 || count < 0 || count > array.Length)
- throw new ArgumentException();
- NewArray = new double[count];
- for (var i = 0; i < count; i++)
- NewArray[i] = array[i + position];
- this.array = array;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement