comparison src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/FunctionThread.java @ 15:89478f2ea07f

change src name TimeMeasurementJuGrix to TimeMeasurementJuGrixFunction
author one
date Mon, 08 Dec 2014 01:08:03 +0900
parents 7c544969d4c9
children
comparison
equal deleted inserted replaced
14:047bbe894005 15:89478f2ea07f
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; 7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; 8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser;
9 9
10 public class FunctionThread extends Thread { 10 public class FunctionThread extends Thread {
11 11
12 JungleTree tree; 12 JungleTree tree;
13 int findCount; 13 int findCount;
14 boolean loop = true; 14 boolean loop = true;
15 15
16 public FunctionThread(JungleTree tree) { 16 public FunctionThread(JungleTree tree) {
17 this.tree = tree; 17 this.tree = tree;
18 this.findCount = 0; 18 this.findCount = 0;
19 } 19 }
20 20
21 public int getFindCount() { 21 public int getFindCount() {
22 return findCount; 22 return findCount;
23 } 23 }
24 24
25 public void set(boolean loop) { 25 public void set(boolean loop) {
26 this.loop = loop; 26 this.loop = loop;
27 } 27 }
28
29 @Override
30 public void run() {
31 while (loop) {
32
33 Random rnd = new Random();
34 String value = String.valueOf(rnd .nextInt(1000));
35 InterfaceTraverser traverser = tree.getTraverser(true);
36 Iterator<TreeNode> resultIterator = traverser.find((TreeNode node) -> {
37 String nodeValue = node.getAttributes().getString("KEY");
38 if (nodeValue == null)
39 return false;
40 if (nodeValue.equals(value))
41 return true;
42 return false;
43 }, "KEY", "3");
44 28
45 for (; resultIterator.hasNext();) { 29 @Override
46 resultIterator.next(); 30 public void run() {
47 } 31 while (loop) {
32
33 findCount++;
34 Random rnd = new Random();
48 35
49 findCount++; 36 String value = String.valueOf(rnd.nextInt(1000));
37 InterfaceTraverser traverser = tree.getTraverser(true);
38 Iterator<TreeNode> resultIterator = traverser.find(
39 (TreeNode node) -> {
40 String nodeValue = node.getAttributes()
41 .getString("KEY");
42 if (nodeValue == null)
43 return false;
44 if (nodeValue.equals(value))
45 return true;
46 return false;
47 }, "KEY", value);
48
49 for (; resultIterator.hasNext();) {
50 resultIterator.next();
51 }
52
53 }
50 } 54 }
51 }
52 } 55 }