Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace PO_LAB4
  9. {
  10. public partial class MyList<T>: IEnumerable<T>
  11. {
  12. class MyEnumerator : IEnumerator<T>
  13. {
  14. Node fisrst, current;
  15.  
  16. public MyEnumerator(Node first)
  17. {
  18. this.fisrst = first = this.current = new Node { next = first };
  19. }
  20.  
  21. public T Current => this.current.value;
  22.  
  23. object IEnumerator.Current => Current;
  24.  
  25. public void Dispose()
  26. {
  27. // destruktor
  28. }
  29.  
  30. public bool MoveNext()
  31. {
  32. if (current != null)
  33. current = current.next;
  34. return current != null;
  35. }
  36.  
  37. public void Reset()
  38. {
  39. current = fisrst;
  40. }
  41. }
  42.  
  43. public IEnumerator<T> GetEnumerator()
  44. {
  45. return new MyEnumerator(first);
  46. }
  47.  
  48. IEnumerator IEnumerable.GetEnumerator()
  49. {
  50. return new MyEnumerator(first);
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement