Mercurial > hg > Database > jungle-sharp
comparison 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 |
comparison
equal
deleted
inserted
replaced
9:e6ad9016601c | 10:abe0c247f5a5 |
---|---|
1 using UnityEngine; | |
2 using System.Collections.Generic; | |
3 using System.Collections; | |
4 | |
5 public class DefaultNodePath : NodePath { | |
6 private List<int> path = new List<int>(); | |
7 | |
8 IEnumerator IEnumerable.GetEnumerator() | |
9 { | |
10 // call the generic version of the method | |
11 return this.GetEnumerator(); | |
12 } | |
13 | |
14 public IEnumerator<int> GetEnumerator() | |
15 { | |
16 return path.iterator (); | |
17 } | |
18 | |
19 public DefaultNodePath() { | |
20 path = new List<int> ().addLast (-1); | |
21 } | |
22 | |
23 private DefaultNodePath(List<int> path) { | |
24 this.path = path; | |
25 } | |
26 | |
27 /// <summary> | |
28 /// Listに追加します。 | |
29 /// path = path.add(0)を2回する | |
30 /// path = path.add(0).add(0)する | |
31 /// これは同じ | |
32 /// </summary> | |
33 /// <param name="pos">Position.</param> | |
34 | |
35 public NodePath add(int pos) { | |
36 List<int> newPath = path.addLast(pos); | |
37 return new DefaultNodePath(newPath); | |
38 } | |
39 | |
40 public Pair<int, NodePath> pop() { | |
41 int head = path.headList(); | |
42 List<int> tail = path.deleteHead(); | |
43 return new Pair<int, NodePath>(head, new DefaultNodePath(tail)); | |
44 } | |
45 | |
46 public Pair<int, NodePath> last() { | |
47 int last = path.headList(); | |
48 List<int> list = path.deleteHead(); | |
49 return new Pair<int, NodePath>(last, new DefaultNodePath(list)); | |
50 } | |
51 | |
52 public override string ToString() { | |
53 string s = "List <"; | |
54 int list_count = this.path.length(); | |
55 int count = 0; | |
56 foreach(var i in this.path) { | |
57 if (count != list_count -1){ | |
58 s += i.ToString() + ","; | |
59 } else { | |
60 s += i.ToString(); | |
61 } | |
62 count++; | |
63 } | |
64 return s + ">"; | |
65 } | |
66 | |
67 public int size() { | |
68 return path.length(); | |
69 } | |
70 | |
71 public NodePath tail() { | |
72 List<int> tail = path.deleteLast (); | |
73 return new DefaultNodePath (tail); | |
74 } | |
75 | |
76 public List<DefaultNodePath> inits() { | |
77 List<DefaultNodePath> paths = new List<DefaultNodePath> (); | |
78 List<int> coursePath = new List<int> (); | |
79 foreach (int tmpPath in path) { | |
80 List<int> tmp = coursePath.addLast (tmpPath); | |
81 paths = paths.addLast (new DefaultNodePath (tmp)); | |
82 coursePath = tmp; | |
83 } | |
84 return paths; | |
85 } | |
86 | |
87 | |
88 } |