Mercurial > hg > Database > jungle-sharp
comparison src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/logger/DefaultTreeOperationLog.cs @ 0:dec15de2c6ff
first commit
author | Kazuma |
---|---|
date | Tue, 21 Jun 2016 17:11:12 +0900 |
parents | |
children | 02b2ab7bffe6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:dec15de2c6ff |
---|---|
1 using UnityEngine; | |
2 using System.Collections.Generic; | |
3 using System; | |
4 using System.Collections; | |
5 using System.Linq; | |
6 | |
7 | |
8 public class DefaultTreeOperationLog : TreeOperationLog { | |
9 private IEnumerable<TreeOperation> list; | |
10 private int size; | |
11 | |
12 TreeOperation[] _array; | |
13 TreeOperation Count; | |
14 | |
15 IEnumerator IEnumerable.GetEnumerator() | |
16 { | |
17 // call the generic version of the method | |
18 return this.GetEnumerator(); | |
19 } | |
20 | |
21 public IEnumerator<TreeOperation> GetEnumerator() | |
22 { | |
23 for (int i = 0; i < Convert.ToInt32(Count); i++) | |
24 yield return _array[i]; | |
25 } | |
26 | |
27 | |
28 public DefaultTreeOperationLog() | |
29 { | |
30 list = new List<TreeOperation>(); | |
31 size = 0; | |
32 } | |
33 | |
34 public DefaultTreeOperationLog(IEnumerable<TreeOperation> _list,int _size) | |
35 { | |
36 list = _list; | |
37 size = _size; | |
38 } | |
39 | |
40 // public IEnumerator<TreeOperation> iterator() | |
41 // { | |
42 // return list.itetator(); | |
43 // } | |
44 | |
45 public TreeOperationLog add(NodePath _p, NodeOperation _op) | |
46 { | |
47 TreeOperation op = new DefaultTreeOperation(_p,_op); | |
48 List<TreeOperation> newList = new List<TreeOperation>(op); | |
49 // java write Iterables.concat ここは間違い | |
50 IEnumerable<TreeOperation> concat = list.Union<TreeOperation>(newList); | |
51 | |
52 return new DefaultTreeOperationLog(concat,size + 1); | |
53 } | |
54 | |
55 public TreeOperationLog append(TreeOperationLog _log) | |
56 { | |
57 int argumentLogSize = _log.length(); | |
58 // java write Iterables.concat | |
59 IEnumerable<TreeOperation> concat = list.Union<TreeOperation>(_log); | |
60 | |
61 return new DefaultTreeOperationLog(concat,argumentLogSize + size); | |
62 } | |
63 | |
64 | |
65 public int length(){ | |
66 return size; | |
67 } | |
68 } |