Advertisement
Guest User

Untitled

a guest
May 21st, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public class Set : IEnumerable
  2. {
  3. public class SetEnumerator : IEnumerator
  4. {
  5. int index;
  6. Set set = null;
  7.  
  8. public bool MoveNext()
  9. {
  10. index++;
  11. if (index >= set.GetSize())
  12. return false;
  13. else
  14. return true;
  15. }
  16.  
  17. public object Current {
  18. get { return set.GetAtIndex(index); }
  19. }
  20.  
  21. public void Reset()
  22. {
  23. index = -1;
  24. }
  25.  
  26. public SetEnumerator(Set mySet)
  27. {
  28. this.set = mySet;
  29. Reset();
  30. }
  31. }
  32.  
  33. public IEnumerator GetEnumerator()
  34. {
  35. return new SetEnumerator(this);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement