comparison Main/jungle-main/store/impl/logger/DefaultTreeOperationLog.cs @ 20:1f99e150f336

fix folder and add Object Mapper.
author Kazuma Takeda
date Thu, 15 Dec 2016 22:52:48 +0900
parents
children f2ea780b3e80
comparison
equal deleted inserted replaced
19:0865819106cf 20:1f99e150f336
1 using UnityEngine;
2 using System.Collections.Generic;
3 using System;
4 using System.Collections;
5 using System.Linq;
6
7 namespace JungleDB {
8 public class DefaultTreeOperationLog : TreeOperationLog {
9 private IEnumerable<TreeOperation> list;
10 private int size;
11
12 IEnumerator IEnumerable.GetEnumerator()
13 {
14 // call the generic version of the method
15 return this.GetEnumerator();
16 }
17
18 public IEnumerator<TreeOperation> GetEnumerator()
19 {
20 foreach (var i in list) {
21 yield return i;
22 }
23 }
24
25
26 public DefaultTreeOperationLog()
27 {
28 list = new List<TreeOperation>();
29 size = 0;
30 }
31
32 public DefaultTreeOperationLog(IEnumerable<TreeOperation> _list,int _size)
33 {
34 list = _list;
35 size = _size;
36 }
37
38 // public IEnumerator<TreeOperation> iterator()
39 // {
40 // return list.itetator();
41 // }
42
43 public TreeOperationLog add(NodePath _p, NodeOperation _op)
44 {
45 TreeOperation op = new DefaultTreeOperation(_p,_op);
46 List<TreeOperation> newList = new List<TreeOperation>(op);
47 // java write Iterables.concat ここは間違い
48 IEnumerable<TreeOperation> concat = list.Union<TreeOperation>(newList);
49
50 return new DefaultTreeOperationLog(concat,size + 1);
51 }
52
53 public TreeOperationLog append(TreeOperationLog _log)
54 {
55 int argumentLogSize = _log.length();
56 // java write Iterables.concat
57 IEnumerable<TreeOperation> concat = list.Union<TreeOperation>(_log);
58
59 return new DefaultTreeOperationLog(concat,argumentLogSize + size);
60 }
61
62
63 public int length(){
64 return size;
65 }
66 }
67 }