-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCEnumerator.cs
45 lines (39 loc) · 960 Bytes
/
CEnumerator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Collections;
using System.Collections.Generic;
namespace CustomList
{
internal class CEnumerator<T> : IEnumerator<T>
{
private readonly CList<T>.Node FirstNode;
private CList<T>.Node CurrentNode;
public CEnumerator(CList<T>.Node startNode)
{
FirstNode = startNode;
}
public T Current => CurrentNode.Value;
object IEnumerator.Current => Current;
public void Dispose()
{
return;
}
public bool MoveNext()
{
if(CurrentNode == null)
{
CurrentNode = FirstNode;
return true;
}
if(CurrentNode.Next == null)
{
return false;
}
CurrentNode = CurrentNode.Next;
return true;
}
public void Reset()
{
CurrentNode = FirstNode;
}
}
}