root/plot/Pybrary.Plot/ListEnumerator.cs

Revision 746, 1.1 kB (checked in by mfenniak, 2 years ago)

--

Line 
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Text;
5
6 namespace Pybrary.Plot
7 {
8     public class ListEnumerator<T> : IEnumerator<T>
9     {
10         private int index = -1;
11         private IList<T> back;
12
13         public ListEnumerator(IList<T> back)
14         {
15             this.back = back;
16         }
17
18         public T Current
19         {
20             get
21             {
22                 if (index < 0 || index >= this.back.Count)
23                     throw new InvalidOperationException();
24                 return this.back[index];
25             }
26         }
27
28         object IEnumerator.Current
29         {
30             get
31             {
32                 if (index < 0 || index >= this.back.Count)
33                     throw new InvalidOperationException();
34                 return this.back[index];
35             }
36         }
37
38         public bool MoveNext()
39         {
40             index++;
41             return index < this.back.Count;
42         }
43
44         public void Reset()
45         {
46             index = -1;
47         }
48
49         public void Dispose()
50         {
51         }
52     }
53 }
Note: See TracBrowser for help on using the browser.