2024-05-04 08:26:16 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
2024-05-05 07:52:06 +00:00
|
|
|
namespace Rokojori
|
2024-05-04 08:26:16 +00:00
|
|
|
{
|
2024-05-05 07:52:06 +00:00
|
|
|
public class SingleIterator<N>: TreeIterator<N> where N:class
|
2024-05-04 08:26:16 +00:00
|
|
|
{
|
|
|
|
N node;
|
|
|
|
N current;
|
|
|
|
|
2024-05-05 07:52:06 +00:00
|
|
|
public static SingleIterator<N> Create( N node )
|
2024-05-04 08:26:16 +00:00
|
|
|
{
|
2024-05-05 07:52:06 +00:00
|
|
|
var iterator = new SingleIterator<N>();
|
2024-05-04 08:26:16 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|