annotate src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkNodePath.cs @ 12:b71d9ea6bd8e

Add Network Operation Class. this codes can not test yet.
author Kazuma
date Sun, 23 Oct 2016 12:25:57 +0900
parents
children 4c8932dad7b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
1 using UnityEngine;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
2 using System.Collections;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
3 using System.Collections.Generic;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
4
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
5 public class NetworkNodePath : NodePath {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
6 LinkedList<int> Path;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
7
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
8 public NetworkNodePath () {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
9 Path = new LinkedList<int>();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
10 Path.AddFirst(-1);
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
11 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
12
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
13 public NetworkNodePath (NodePath path){
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
14 Path = new LinkedList<int>();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
15 foreach(int p in path) {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
16 Path.AddLast(p);
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
17 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
18 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
19
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
20 private NetworkNodePath (LinkedList<int> path) {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
21 this.Path = path;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
22 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
23
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
24 public IEnumerator<int> iterator () { // iterator error.
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
25 yield return this.Path.GetEnumerator().Current;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
26 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
27
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
28 IEnumerator IEnumerable.GetEnumerator()
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
29 {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
30 return this.GetEnumerator();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
31 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
32
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
33 public IEnumerator<int> GetEnumerator()
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
34 {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
35 return iterator ();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
36 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
37
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
38 public NodePath add (int pos) {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
39 LinkedList<int> newPath = copyPath();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
40 newPath.AddLast(pos);
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
41 return new NetworkNodePath(newPath);
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
42 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
43
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
44 public NodePath addHead(int pos) { // still java code.
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
45 LinkedList<int> newPath = copyPath();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
46 newPath.AddFirst(pos);
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
47 return new NetworkNodePath(newPath);
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
48 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
49
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
50 public Pair<int, NodePath> pop () {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
51 LinkedList<int> cPath = copyPath();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
52 int e = cPath.First.Value;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
53 cPath.RemoveFirst();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
54 return new Pair<int, NodePath>(e, new NetworkNodePath(cPath));
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
55 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
56
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
57 public int size () {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
58 return this.Path.Count;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
59 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
60
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
61
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
62 public LinkedList<int> copyPath(){
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
63 LinkedList<int> newPath = new LinkedList<int>();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
64 foreach(int i in this.Path) {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
65 newPath.AddLast(i);
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
66 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
67 return newPath;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
68 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
69
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
70 public override string ToString () {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
71 return Path.ToString();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
72 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
73
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
74 public NodePath tail() {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
75 this.Path.RemoveLast();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
76 return new NetworkNodePath(this.Path);
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
77 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
78
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
79 public Pair<int, NodePath> last () {
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
80 int lastValue = this.Path.Last.Value;
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
81 this.Path.RemoveLast();
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
82 return new Pair<int, NodePath>(lastValue, new NetworkNodePath(this.Path));
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
83 }
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
84
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
85
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
86
b71d9ea6bd8e Add Network Operation Class. this codes can not test yet.
Kazuma
parents:
diff changeset
87 }