Ejemplo n.º 1
0
 @Override
 default <U> Tree<Tuple2<T, U>> zip(Iterable<U> that) {
   Objects.requireNonNull(that, "that is null");
   if (isEmpty()) {
     return Empty.instance();
   } else {
     return Zip.apply((Node<T>) this, that.iterator());
   }
 }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 static <T, U> Tree<Tuple2<T, U>> apply(Node<T> node, java.util.Iterator<U> that) {
   if (!that.hasNext()) {
     return Empty.instance();
   } else {
     final Tuple2<T, U> value = Tuple.of(node.getValue(), that.next());
     final List<Node<Tuple2<T, U>>> children =
         (List<Node<Tuple2<T, U>>>)
             (Object)
                 node.getChildren().map(child -> Zip.apply(child, that)).filter(Tree::isDefined);
     return new Node<>(value, children);
   }
 }