Guest User

Untitled

a guest
Jul 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Collections;
  6.  
  7. namespace AlgoDS_Labb1
  8. {
  9.    
  10.     class BagEnumerator<T> : IEnumerator<T>
  11.     {
  12.         private Bag<T> thebag;
  13.  
  14.         public BagEnumerator(Bag<T> a)
  15.         {
  16.             thebag = a;
  17.         }
  18.  
  19.         int position = -1;
  20.  
  21.         public T Current
  22.         {
  23.             get
  24.             {
  25.                 return thebag.IndexReturn(position);
  26.             }
  27.         }
  28.  
  29.         object IEnumerator.Current
  30.         {
  31.             get
  32.             {
  33.                 return Current;
  34.             }
  35.         }
  36.  
  37.         public bool MoveNext()
  38.         {
  39.             position++;
  40.             return (position < thebag.Items.Length);
  41.         }
  42.  
  43.         public void Reset()
  44.         {
  45.             position = -1;
  46.         }
  47.  
  48.         public void Dispose()
  49.         {
  50.        
  51.         }
  52.     }
  53. }
Add Comment
Please, Sign In to add comment