38 lines
629 B
C#
38 lines
629 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
|
||
|
namespace Rokojori.Core
|
||
|
{
|
||
|
public class SinlgeIterator<N>: TreeIterator<N> where N:class
|
||
|
{
|
||
|
N node;
|
||
|
N current;
|
||
|
|
||
|
public static SinlgeIterator<N> Create( N node )
|
||
|
{
|
||
|
var iterator = new SinlgeIterator<N>();
|
||
|
|
||
|
iterator.node = node;
|
||
|
iterator.current = null;
|
||
|
|
||
|
return iterator;
|
||
|
}
|
||
|
|
||
|
public override bool HasNext()
|
||
|
{
|
||
|
return node != null;
|
||
|
}
|
||
|
|
||
|
public override N Current()
|
||
|
{
|
||
|
return current;
|
||
|
}
|
||
|
|
||
|
protected override void _MoveToNext()
|
||
|
{
|
||
|
current = node;
|
||
|
node = null;
|
||
|
}
|
||
|
}
|
||
|
}
|