using System;
using System.Collections;
using System.Collections.Generic;
namespace MrWu.core
{
///
///
///
public struct ArrayEnumerator : IEnumerator, IEnumerator
{
private T[] array;
private int index;
private T current;
///
/// 迭代器
///
///
public ArrayEnumerator(T[] array) {
this.array = array;
index = 0;
current = default(T);
}
///
/// 下一个
///
///
public bool MoveNext() {
if (index < array.Length) {
current = array[index];
index++;
return true;
}
return MoveNextRare();
}
private bool MoveNextRare() {
index = array.Length + 1;
return false;
}
///
/// 当前的值
///
public T Current {
get {
return current;
}
}
Object IEnumerator.Current {
get {
return Current;
}
}
///
///
///
public void Dispose() { }
///
/// 重置
///
public void Reset() {
index = 0;
current = default(T);
}
}
}