using UnityEngine; using System.Collections.Generic; using System.Collections; public class DefaultNodePath : NodePath { private List path = new List(); IEnumerator IEnumerable.GetEnumerator() { // call the generic version of the method return this.GetEnumerator(); } public IEnumerator GetEnumerator() { return path.iterator (); } public DefaultNodePath() { path = new List ().addLast (-1); } private DefaultNodePath(List path) { this.path = path; } /// /// Listに追加します。 /// path = path.add(0)を2回する /// path = path.add(0).add(0)する /// これは同じ /// /// Position. 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 override string ToString() { string s = "List <"; int list_count = this.path.length(); int count = 0; foreach(var i in this.path) { if (count != list_count -1){ s += i.ToString() + ","; } else { s += i.ToString(); } count++; } return s + ">"; } 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; } }