Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Incapsulation.Weights
  8. {
  9. public class Indexer
  10. {
  11. private double[] array;
  12. public readonly int Position;
  13. public double[] NewArray;
  14. public int Length
  15. {
  16. get
  17. {
  18. return NewArray.Length;
  19. }
  20. }
  21.  
  22. public double this[int index]
  23. {
  24. get
  25. {
  26. if (index < 0 || index > NewArray.Length)
  27. throw new IndexOutOfRangeException();
  28. return NewArray[index];
  29. }
  30. set
  31. {
  32. if (index >= Length)
  33. throw new IndexOutOfRangeException();
  34. NewArray[index] = value;
  35. array[index + Position] = value;
  36. }
  37. }
  38. public Indexer(double[] array, int position, int count)
  39. {
  40. Position = position;
  41. if (position < 0 || count < 0 || count > array.Length)
  42. throw new ArgumentException();
  43. NewArray = array.Skip(position).Take(count).ToArray();
  44. this.array = array;
  45.  
  46.  
  47.  
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement