Mercurial > hg > Database > jungle-sharp
comparison src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/DefaultNodePath.cs @ 7:02b2ab7bffe6
fix
author | Kazuma |
---|---|
date | Tue, 27 Sep 2016 18:36:05 +0900 |
parents | dec15de2c6ff |
children | d132d442dc34 |
comparison
equal
deleted
inserted
replaced
5:0428c8888abf | 7:02b2ab7bffe6 |
---|---|
2 using System.Collections.Generic; | 2 using System.Collections.Generic; |
3 using System.Collections; | 3 using System.Collections; |
4 | 4 |
5 public class DefaultNodePath : NodePath { | 5 public class DefaultNodePath : NodePath { |
6 private List<int> path = new List<int>(); | 6 private List<int> path = new List<int>(); |
7 | |
8 int[] _array; | |
9 int Count; | |
10 | 7 |
11 IEnumerator IEnumerable.GetEnumerator() | 8 IEnumerator IEnumerable.GetEnumerator() |
12 { | 9 { |
13 // call the generic version of the method | 10 // call the generic version of the method |
14 return this.GetEnumerator(); | 11 return this.GetEnumerator(); |
15 } | 12 } |
16 | 13 |
17 public IEnumerator<int> GetEnumerator() | 14 public IEnumerator<int> GetEnumerator() |
18 { | 15 { |
19 for (int i = 0; i < Count; i++) | 16 return path.iterator (); |
20 yield return _array[i]; | |
21 } | |
22 | |
23 | |
24 | |
25 public void Start() { | |
26 NodePath p = new DefaultNodePath(); | |
27 p = p.add(1).add(2).add(3).add(4); | |
28 Debug.Log (p.ToString ()); | |
29 } | 17 } |
30 | 18 |
31 public DefaultNodePath() { | 19 public DefaultNodePath() { |
32 path = new List<int> ().addLast (-1); | 20 path = new List<int> ().addLast (-1); |
33 } | 21 } |
34 | 22 |
35 private DefaultNodePath(List<int> path) { | 23 private DefaultNodePath(List<int> path) { |
36 this.path = path; | 24 this.path = path; |
37 } | 25 } |
38 | 26 |
39 | 27 /// <summary> |
40 // public IEnumerator<int> iterator() { | 28 /// Listに追加します。 |
41 // return path.iterator(); | 29 /// path = path.add(0)を2回する |
42 // } | 30 /// path = path.add(0).add(0)する |
31 /// これは同じ | |
32 /// </summary> | |
33 /// <param name="pos">Position.</param> | |
43 | 34 |
44 public NodePath add(int pos) { | 35 public NodePath add(int pos) { |
45 List<int> newPath = path.addLast(pos); | 36 List<int> newPath = path.addLast(pos); |
46 return new DefaultNodePath(newPath); | 37 return new DefaultNodePath(newPath); |
47 } | 38 } |
56 int last = path.headList(); | 47 int last = path.headList(); |
57 List<int> list = path.deleteHead(); | 48 List<int> list = path.deleteHead(); |
58 return new Pair<int, NodePath>(last, new DefaultNodePath(list)); | 49 return new Pair<int, NodePath>(last, new DefaultNodePath(list)); |
59 } | 50 } |
60 | 51 |
61 public string toString() { | 52 public override string ToString() { |
62 return path.toString(); | 53 return path.toString(); |
63 } | 54 } |
64 | 55 |
65 public int size() { | 56 public int size() { |
66 return path.length(); | 57 return path.length(); |