private List<SpanNode> getSpanNodes() { ArrayList<SpanNode> nodes = new ArrayList<SpanNode>(); nodes.add(root); Iterator<SpanNode> it = root.childIteratorRecursive(); while (it.hasNext()) { nodes.add(it.next()); } return nodes; }
@Override Iterator<Annotation> iteratorRecursive(SpanNode node) { IdentityHashMap<SpanNode, SpanNode> nodes = new IdentityHashMap<SpanNode, SpanNode>(); nodes.put(node, node); { Iterator<SpanNode> childrenIt = node.childIteratorRecursive(); while (childrenIt.hasNext()) { SpanNode child = childrenIt.next(); nodes.put(child, child); } } return iterator(nodes); }
private static IdentityHashMap<SpanNode, Integer> getSpanNodes(SpanTree otherToCopy) { IdentityHashMap<SpanNode, Integer> map = new IdentityHashMap<SpanNode, Integer>(); int spanNodeCounter = 0; map.put(otherToCopy.getRoot(), spanNodeCounter++); Iterator<SpanNode> it = otherToCopy.getRoot().childIteratorRecursive(); while (it.hasNext()) { map.put(it.next(), spanNodeCounter++); } return map; }
@Override @SuppressWarnings("unchecked") Iterator<Annotation> iteratorRecursive(SpanNode node) { IdentityHashMap<SpanNode, SpanNode> nodes = new IdentityHashMap<SpanNode, SpanNode>(); nodes.put(node, node); { Iterator<SpanNode> childrenIt = node.childIteratorRecursive(); while (childrenIt.hasNext()) { SpanNode child = childrenIt.next(); nodes.put(child, child); } } List<Collection<Annotation>> annotationLists = new ArrayList<Collection<Annotation>>(nodes.size()); for (SpanNode includedNode : nodes.keySet()) { Collection<Annotation> includedAnnotations = spanNode2Annotation.getCollection(includedNode); if (includedAnnotations != null) { annotationLists.add(includedAnnotations); } } return new AnnotationCollectionIterator(annotationLists); }