Mercurial > hg > Members > tatsuki > bench > jungle-core
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/DefaultIndexEditor.java @ 151:d9fbddf77bf6
add class Index
author | one |
---|---|
date | Sat, 22 Nov 2014 14:46:44 +0900 |
parents | feb2346ace19 |
children | 8a0aa8fc137c |
comparison
equal
deleted
inserted
replaced
150:1432adf6f490 | 151:d9fbddf77bf6 |
---|---|
7 import fj.data.Option; | 7 import fj.data.Option; |
8 import fj.data.TreeMap; | 8 import fj.data.TreeMap; |
9 | 9 |
10 public class DefaultIndexEditor implements IndexEditor { | 10 public class DefaultIndexEditor implements IndexEditor { |
11 | 11 |
12 TreeMap<String, TreeMap<String, List<TreeNode>>> indexTreeMap; | 12 Index index; |
13 | 13 |
14 public DefaultIndexEditor(TreeMap<String, TreeMap<String, List<TreeNode>>> indexTreeMap) { | 14 public DefaultIndexEditor(Index index) { |
15 this.indexTreeMap = indexTreeMap; | 15 this.index = index; |
16 } | 16 } |
17 | 17 |
18 @Override | 18 @Override |
19 public IndexEditor delete(TreeNode node) { | 19 public IndexEditor delete(TreeNode node) { |
20 TreeNodeAttributes attribute = node.getAttributes(); | 20 TreeNodeAttributes attribute = node.getAttributes(); |
21 List<String> keys = attribute.getKeys(); | 21 List<String> keys = attribute.getKeys(); |
22 TreeMap<String, TreeMap<String, List<TreeNode>>> newIndexTreeMap = indexTreeMap; | 22 Index newIndexTreeMap = index; |
23 for (String key : keys) { | 23 for (String key : keys) { |
24 Option<TreeMap<String, List<TreeNode>>> indexOp = indexTreeMap.get(key); | 24 Option<TreeMap<String, List<TreeNode>>> indexOp = index.get(key); |
25 if (indexOp.isSome()) { | 25 if (indexOp.isSome()) { |
26 TreeMap<String, List<TreeNode>> index = indexOp.some(); | 26 TreeMap<String, List<TreeNode>> index = indexOp.some(); |
27 String value = attribute.getString(key); | 27 String value = attribute.getString(key); |
28 Option<List<TreeNode>> nodeListOp = index.get(value); | 28 Option<List<TreeNode>> nodeListOp = index.get(value); |
29 if (nodeListOp.isSome()) { | 29 if (nodeListOp.isSome()) { |
46 | 46 |
47 @Override | 47 @Override |
48 public IndexEditor add(TreeNode node) { | 48 public IndexEditor add(TreeNode node) { |
49 TreeNodeAttributes attribute = node.getAttributes(); | 49 TreeNodeAttributes attribute = node.getAttributes(); |
50 List<String> keys = attribute.getKeys(); | 50 List<String> keys = attribute.getKeys(); |
51 TreeMap<String, TreeMap<String, List<TreeNode>>> newIndexTreeMap = indexTreeMap; | 51 TreeMap<String, TreeMap<String, List<TreeNode>>> newIndexTreeMap = index; |
52 for (String key : keys) { | 52 for (String key : keys) { |
53 Option<TreeMap<String, List<TreeNode>>> indexOp = indexTreeMap.get(key); | 53 Option<TreeMap<String, List<TreeNode>>> indexOp = index.get(key); |
54 if (indexOp.isSome()) { | 54 if (indexOp.isSome()) { |
55 TreeMap<String, List<TreeNode>> index = indexOp.some(); | 55 TreeMap<String, List<TreeNode>> index = indexOp.some(); |
56 String value = attribute.getString(key); | 56 String value = attribute.getString(key); |
57 Option<List<TreeNode>> nodeListOp = index.get(value); | 57 Option<List<TreeNode>> nodeListOp = index.get(value); |
58 if (nodeListOp.isSome()) { | 58 if (nodeListOp.isSome()) { |
81 return new DefaultIndexEditor(newIndexTreeMap); | 81 return new DefaultIndexEditor(newIndexTreeMap); |
82 } | 82 } |
83 | 83 |
84 @Override | 84 @Override |
85 public TreeMap<String, TreeMap<String, List<TreeNode>>> getIndex() { | 85 public TreeMap<String, TreeMap<String, List<TreeNode>>> getIndex() { |
86 return indexTreeMap; | 86 return index; |
87 } | 87 } |
88 | 88 |
89 @Override | 89 @Override |
90 public IndexEditor edit(TreeNode node) { | 90 public IndexEditor edit(TreeNode node) { |
91 return this; | 91 return this; |