35
|
1 using System.Collections;
|
20
|
2
|
|
3 namespace JungleDB {
|
|
4 public class DefaultEvaluator : Evaluator {
|
|
5 private NodePath path;
|
|
6
|
|
7 public DefaultEvaluator(NodePath _path) {
|
|
8 path = _path;
|
|
9 }
|
|
10
|
|
11 public Evaluation evaluate(TreeNode _current, int _pos){
|
|
12 Pair<int, NodePath> pop = path.pop ();
|
|
13 int head = pop.lefts ();
|
|
14
|
|
15 if (path.size () == 1) {
|
|
16 if (head == _pos) {
|
|
17 return new DefaultEvaluation (Result.GOAL, null);
|
|
18 }
|
|
19 }
|
|
20
|
|
21 DefaultEvaluator nextEvaluator;
|
|
22 Result result;
|
|
23 if (head == _pos) {
|
|
24 result = Result.ACCEPT;
|
|
25 nextEvaluator = new DefaultEvaluator (pop.rights ());
|
|
26 } else {
|
|
27 result = Result.CONTINUE;
|
|
28 nextEvaluator = null;
|
|
29 }
|
|
30
|
|
31 return new DefaultEvaluation (result, nextEvaluator);
|
|
32 }
|
|
33 }
|
|
34 }
|