diff src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/store/impl/DefaultNodePath.cs @ 10:abe0c247f5a5

Add Network module. but, unComplete NetworkDefaultJungleTreeEditor.cs
author Kazuma Takeda <kazuma-arashi@hotmail.co.jp>
date Sun, 23 Oct 2016 07:40:50 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/store/impl/DefaultNodePath.cs	Sun Oct 23 07:40:50 2016 +0900
@@ -0,0 +1,88 @@
+using UnityEngine;
+using System.Collections.Generic;
+using System.Collections;
+
+public class DefaultNodePath : NodePath {
+	private List<int> path = new List<int>();
+
+	IEnumerator IEnumerable.GetEnumerator()
+	{
+		// call the generic version of the method
+		return this.GetEnumerator();
+	}
+
+	public IEnumerator<int> GetEnumerator()
+	{
+		return path.iterator ();
+	}
+
+	public DefaultNodePath() {
+		path = new List<int> ().addLast (-1);
+	}
+
+	private DefaultNodePath(List<int> path) {
+		this.path = path;
+	}
+
+	/// <summary>
+	/// Listに追加します。
+	/// path = path.add(0)を2回する
+	/// path = path.add(0).add(0)する
+	/// これは同じ
+	/// </summary>
+	/// <param name="pos">Position.</param>
+
+	public NodePath add(int pos) {
+		List<int> newPath = path.addLast(pos);
+		return new DefaultNodePath(newPath);
+	}
+
+	public Pair<int, NodePath> pop() {
+		int head = path.headList();
+		List<int> tail = path.deleteHead();
+		return new Pair<int, NodePath>(head, new DefaultNodePath(tail));
+	}
+
+	public Pair<int, NodePath> last() {
+		int last = path.headList();
+		List<int> list = path.deleteHead();
+		return new Pair<int, NodePath>(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<int> tail = path.deleteLast ();
+		return new DefaultNodePath (tail);
+	}
+
+	public List<DefaultNodePath> inits() {
+		List<DefaultNodePath> paths = new List<DefaultNodePath> ();
+		List<int> coursePath = new List<int> ();
+		foreach (int tmpPath in path) {
+			List<int> tmp = coursePath.addLast (tmpPath);
+			paths = paths.addLast (new DefaultNodePath (tmp));
+			coursePath = tmp;
+		}
+		return paths;
+	}
+
+
+}