using UnityEngine; using System.Collections.Generic; using System.Collections; public class DefaultNodePath : NodePath { private List path = new List(); int[] _array; int Count; IEnumerator IEnumerable.GetEnumerator() { // call the generic version of the method return this.GetEnumerator(); } public IEnumerator GetEnumerator() { for (int i = 0; i < Count; i++) yield return _array[i]; } public void Start() { NodePath p = new DefaultNodePath(); p = p.add(1).add(2).add(3).add(4); Debug.Log (p.ToString ()); } public DefaultNodePath() { path = new List ().addLast (-1); } private DefaultNodePath(List path) { this.path = path; } // public IEnumerator iterator() { // return path.iterator(); // } public NodePath add(int pos) { List newPath = path.addLast(pos); return new DefaultNodePath(newPath); } public Pair pop() { int head = path.headList(); List tail = path.deleteHead(); return new Pair(head, new DefaultNodePath(tail)); } public Pair last() { int last = path.headList(); List list = path.deleteHead(); return new Pair(last, new DefaultNodePath(list)); } public string toString() { return path.toString(); } public int size() { return path.length(); } public NodePath tail() { List tail = path.deleteLast (); return new DefaultNodePath (tail); } public List inits() { List paths = new List (); List coursePath = new List (); foreach (int tmpPath in path) { List tmp = coursePath.addLast (tmpPath); paths = paths.addLast (new DefaultNodePath (tmp)); coursePath = tmp; } return paths; } }