| 78 | } |
| 79 | |
| 80 | private static void query(Map<Integer, Node> nodes, Record[] query, |
| 81 | List<Instance> stack, int index) |
| 82 | { |
| 83 | Node node = nodes.get(peek(stack, index).key); |
| 84 | if (node != null) { |
| 85 | int base = node.index(); |
| 86 | for (int i = base + 1; i < query.length; ++i) { |
| 87 | int peek = index + i - base; |
| 88 | if (peek < stack.size()) { |
| 89 | Instance instance = peek(stack, peek); |
| 90 | if (query[i] == instance.record) { |
| 91 | TreeNode next = (TreeNode) nodes.get(instance); |
| 92 | if (next == null) { |
| 93 | nodes.put(instance.key, next = new TreeNode(instance, i)); |
| 94 | } |
| 95 | next.children.add(node); |
| 96 | node = next; |
| 97 | } else { |
| 98 | return; |
| 99 | } |
| 100 | } else { |
| 101 | return; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | if (index + query.length - base < stack.size()) { |
| 106 | nodes(peek(stack, index + query.length - base).record).add(node); |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | private static void query(Map<Integer, Node> nodes, Record[] query, |
| 112 | List<Instance> stack) |