Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PO_LAB4
- {
- public partial class MyList<T>: IEnumerable<T>
- {
- class MyEnumerator : IEnumerator<T>
- {
- Node fisrst, current;
- public MyEnumerator(Node first)
- {
- this.fisrst = first = this.current = new Node { next = first };
- }
- public T Current => this.current.value;
- object IEnumerator.Current => Current;
- public void Dispose()
- {
- // destruktor
- }
- public bool MoveNext()
- {
- if (current != null)
- current = current.next;
- return current != null;
- }
- public void Reset()
- {
- current = fisrst;
- }
- }
- public IEnumerator<T> GetEnumerator()
- {
- return new MyEnumerator(first);
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return new MyEnumerator(first);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement