changeset 8098:689cf91b8f81

More cleanup in Node/NodeUtils
author briangoetz
date Fri, 12 Apr 2013 12:56:52 -0400
parents 15e1cce39200
children b41092d39293
files src/share/classes/java/util/stream/DoublePipeline.java src/share/classes/java/util/stream/IntPipeline.java src/share/classes/java/util/stream/LongPipeline.java src/share/classes/java/util/stream/NodeUtils.java src/share/classes/java/util/stream/Nodes.java src/share/classes/java/util/stream/ReferencePipeline.java src/share/classes/java/util/stream/SliceOps.java src/share/classes/java/util/stream/SortedOps.java test-ng/boottests/java/util/stream/DoubleNodeTest.java test-ng/boottests/java/util/stream/IntNodeTest.java test-ng/boottests/java/util/stream/LongNodeTest.java test-ng/boottests/java/util/stream/NodeBuilderTest.java test-ng/boottests/java/util/stream/NodeTest.java
diffstat 13 files changed, 216 insertions(+), 270 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/DoublePipeline.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/src/share/classes/java/util/stream/DoublePipeline.java	Fri Apr 12 12:56:52 2013 -0400
@@ -126,7 +126,7 @@
                                              Spliterator<P_IN> spliterator,
                                              boolean flattenTree,
                                              IntFunction<Double[]> generator) {
-        return NodeUtils.doubleCollect(helper, spliterator, flattenTree);
+        return NodeUtils.collectDouble(helper, spliterator, flattenTree);
     }
 
     @Override
@@ -150,7 +150,7 @@
 
     @Override
     final  Node.Builder<Double> makeNodeBuilder(long exactSizeIfKnown, IntFunction<Double[]> generator) {
-        return Nodes.doubleMakeBuilder(exactSizeIfKnown);
+        return Nodes.doubleBuilder(exactSizeIfKnown);
     }
 
 
@@ -445,7 +445,7 @@
 
     @Override
     public final double[] toArray() {
-        return NodeUtils.doubleFlatten((Node.OfDouble) evaluateToArrayNode(Double[]::new))
+        return NodeUtils.flattenDouble((Node.OfDouble) evaluateToArrayNode(Double[]::new))
                         .asDoubleArray();
     }
 
--- a/src/share/classes/java/util/stream/IntPipeline.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/src/share/classes/java/util/stream/IntPipeline.java	Fri Apr 12 12:56:52 2013 -0400
@@ -122,7 +122,7 @@
                                               Spliterator<P_IN> spliterator,
                                               boolean flattenTree,
                                               IntFunction<Integer[]> generator) {
-        return NodeUtils.intCollect(helper, spliterator, flattenTree);
+        return NodeUtils.collectInt(helper, spliterator, flattenTree);
     }
 
     @Override
@@ -146,7 +146,7 @@
 
     @Override
     final Node.Builder<Integer> makeNodeBuilder(long exactSizeIfKnown, IntFunction<Integer[]> generator) {
-        return Nodes.intMakeBuilder(exactSizeIfKnown);
+        return Nodes.intBuilder(exactSizeIfKnown);
     }
 
 
@@ -474,7 +474,7 @@
 
     @Override
     public final int[] toArray() {
-        return NodeUtils.intFlatten((Node.OfInt) evaluateToArrayNode(Integer[]::new))
+        return NodeUtils.flattenInt((Node.OfInt) evaluateToArrayNode(Integer[]::new))
                         .asIntArray();
     }
 
--- a/src/share/classes/java/util/stream/LongPipeline.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/src/share/classes/java/util/stream/LongPipeline.java	Fri Apr 12 12:56:52 2013 -0400
@@ -122,7 +122,7 @@
                                            Spliterator<P_IN> spliterator,
                                            boolean flattenTree,
                                            IntFunction<Long[]> generator) {
-        return NodeUtils.longCollect(helper, spliterator, flattenTree);
+        return NodeUtils.collectLong(helper, spliterator, flattenTree);
     }
 
     @Override
@@ -146,7 +146,7 @@
 
     @Override
     final Node.Builder<Long> makeNodeBuilder(long exactSizeIfKnown, IntFunction<Long[]> generator) {
-        return Nodes.longMakeBuilder(exactSizeIfKnown);
+        return Nodes.longBuilder(exactSizeIfKnown);
     }
 
 
@@ -459,7 +459,7 @@
 
     @Override
     public final long[] toArray() {
-        return NodeUtils.longFlatten((Node.OfLong) evaluateToArrayNode(Long[]::new)).asLongArray();
+        return NodeUtils.flattenLong((Node.OfLong) evaluateToArrayNode(Long[]::new)).asLongArray();
     }
 
 
--- a/src/share/classes/java/util/stream/NodeUtils.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/src/share/classes/java/util/stream/NodeUtils.java	Fri Apr 12 12:56:52 2013 -0400
@@ -74,8 +74,6 @@
             return Nodes.node(array);
         } else {
             Node<P_OUT> node = new CollectorTask<>(helper, generator, spliterator).invoke();
-
-            // @@@ using default F/J pool, will that be different from that used by helper.invoke?
             return flattenTree ? flatten(node, generator) : node;
         }
     }
@@ -97,7 +95,7 @@
     public static <T> Node<T> flatten(Node<T> node, IntFunction<T[]> generator) {
         if (node.getChildCount() > 0) {
             T[] array = generator.apply((int) node.count());
-            new ToArrayTask<>(node, array, 0).invoke();
+            new ToArrayTask.OfRef<>(node, array, 0).invoke();
             return Nodes.node(array);
         } else {
             return node;
@@ -127,7 +125,7 @@
      * @param <P_IN> type of input elements to the pipeline
      * @return the {@link Node.OfInt} encapsulating the output elements.
      */
-    public static <P_IN> Node.OfInt intCollect(PipelineHelper<Integer> helper,
+    public static <P_IN> Node.OfInt collectInt(PipelineHelper<Integer> helper,
                                                Spliterator<P_IN> spliterator,
                                                boolean flattenTree) {
         long size = helper.exactOutputSizeIfKnown(spliterator);
@@ -136,13 +134,11 @@
                 throw new IllegalArgumentException("Stream size exceeds max array size");
             int[] array = new int[(int) size];
             new SizedCollectorTask.OfInt<>(spliterator, helper, array).invoke();
-            return Nodes.intNode(array);
+            return Nodes.node(array);
         }
         else {
             Node.OfInt node = new IntCollectorTask<>(helper, spliterator).invoke();
-
-            // @@@ using default F/J pool, will that be different from that used by helper.invoke?
-            return flattenTree ? intFlatten(node) : node;
+            return flattenTree ? flattenInt(node) : node;
         }
     }
 
@@ -158,11 +154,11 @@
      * @return a flattened {@code Node.OfInt}. If the input node is already flat then
      * that node is returned directly.
      */
-    public static Node.OfInt intFlatten(Node.OfInt node) {
+    public static Node.OfInt flattenInt(Node.OfInt node) {
         if (node.getChildCount() > 0) {
             int[] array = new int[(int) node.count()];
-            new IntToArrayTask(node, array, 0).invoke();
-            return Nodes.intNode(array);
+            new ToArrayTask.OfInt(node, array, 0).invoke();
+            return Nodes.node(array);
         } else {
             return node;
         }
@@ -191,7 +187,7 @@
      * @param <P_IN> type of input elements to the pipeline
      * @return the {@link Node.OfLong} encapsulating the output elements.
      */
-    public static <P_IN> Node.OfLong longCollect(PipelineHelper<Long> helper,
+    public static <P_IN> Node.OfLong collectLong(PipelineHelper<Long> helper,
                                                  Spliterator<P_IN> spliterator,
                                                  boolean flattenTree) {
         long size = helper.exactOutputSizeIfKnown(spliterator);
@@ -200,13 +196,11 @@
                 throw new IllegalArgumentException("Stream size exceeds max array size");
             long[] array = new long[(int) size];
             new SizedCollectorTask.OfLong<>(spliterator, helper, array).invoke();
-            return Nodes.longNode(array);
+            return Nodes.node(array);
         }
         else {
             Node.OfLong node = new LongCollectorTask<>(helper, spliterator).invoke();
-
-            // @@@ using default F/J pool, will that be different from that used by helper.invoke?
-            return flattenTree ? longFlatten(node) : node;
+            return flattenTree ? flattenLong(node) : node;
         }
     }
 
@@ -222,11 +216,11 @@
      * @return a flattened {@code Node.OfLong}. If the input node is already flat then
      * that node is returned directly.
      */
-    public static Node.OfLong longFlatten(Node.OfLong node) {
+    public static Node.OfLong flattenLong(Node.OfLong node) {
         if (node.getChildCount() > 0) {
             long[] array = new long[(int) node.count()];
-            new LongToArrayTask(node, array, 0).invoke();
-            return Nodes.longNode(array);
+            new ToArrayTask.OfLong(node, array, 0).invoke();
+            return Nodes.node(array);
         } else {
             return node;
         }
@@ -255,7 +249,7 @@
      * @param <P_IN> type of input elements to the pipeline
      * @return the {@link Node.OfDouble} encapsulating the output elements.
      */
-    public static <P_IN> Node.OfDouble doubleCollect(PipelineHelper<Double> helper,
+    public static <P_IN> Node.OfDouble collectDouble(PipelineHelper<Double> helper,
                                                      Spliterator<P_IN> spliterator,
                                                      boolean flattenTree) {
         long size = helper.exactOutputSizeIfKnown(spliterator);
@@ -264,13 +258,11 @@
                 throw new IllegalArgumentException("Stream size exceeds max array size");
             double[] array = new double[(int) size];
             new SizedCollectorTask.OfDouble<>(spliterator, helper, array).invoke();
-            return Nodes.doubleNode(array);
+            return Nodes.node(array);
         }
         else {
             Node.OfDouble node = new DoubleCollectorTask<>(helper, spliterator).invoke();
-
-            // @@@ using default F/J pool, will that be different from that used by helper.invoke?
-            return flattenTree ? doubleFlatten(node) : node;
+            return flattenTree ? flattenDouble(node) : node;
         }
     }
 
@@ -286,11 +278,11 @@
      * @return a flattened {@code Node.OfDouble}. If the input node is already flat then
      * that node is returned directly.
      */
-    public static Node.OfDouble doubleFlatten(Node.OfDouble node) {
+    public static Node.OfDouble flattenDouble(Node.OfDouble node) {
         if (node.getChildCount() > 0) {
             double[] array = new double[(int) node.count()];
-            new DoubleToArrayTask(node, array, 0).invoke();
-            return Nodes.doubleNode(array);
+            new ToArrayTask.OfDouble(node, array, 0).invoke();
+            return Nodes.node(array);
         } else {
             return node;
         }
@@ -321,8 +313,8 @@
 
         @Override
         protected Node<U> doLeaf() {
-            Node.Builder<U> builder = Nodes.makeBuilder(helper.exactOutputSizeIfKnown(spliterator),
-                                                        generator);
+            Node.Builder<U> builder = Nodes.builder(helper.exactOutputSizeIfKnown(spliterator),
+                                                    generator);
             return helper.wrapAndCopyInto(builder, spliterator).build();
         }
 
@@ -531,33 +523,33 @@
         }
     }
 
-    private static final class ToArrayTask<T> extends CountedCompleter<Void> {
-        private final T[] array;
-        private final Node<T> node;
-        private final int offset;
+    private static abstract class ToArrayTask<T, T_NODE extends Node<T>,
+                                              K extends ToArrayTask<T, T_NODE, K>>
+            extends CountedCompleter<Void> {
+        protected final T_NODE node;
+        protected final int offset;
 
-        ToArrayTask(Node<T> node, T[] array, int offset) {
-            this.array = array;
+        ToArrayTask(T_NODE node, int offset) {
             this.node = node;
             this.offset = offset;
         }
 
-        ToArrayTask(ToArrayTask<T> parent, Node<T> node, int offset) {
+        ToArrayTask(K parent, T_NODE node, int offset) {
             super(parent);
-            this.array = parent.array;
             this.node = node;
             this.offset = offset;
         }
 
+        abstract void copyNodeToArray();
+
+        abstract K makeChild(int childIndex, int offset);
+
         @Override
         public void compute() {
-            doCompute(this);
-        }
-
-        private static <T> void doCompute(ToArrayTask<T> task) {
+            ToArrayTask<T, T_NODE, K> task = this;
             while (true) {
                 if (task.node.getChildCount() == 0) {
-                    task.node.copyInto(task.array, task.offset);
+                    task.copyNodeToArray();
                     task.propagateCompletion();
                     return;
                 }
@@ -567,22 +559,114 @@
                     int size = 0;
                     int i = 0;
                     for (;i < task.node.getChildCount() - 1; i++) {
-                        ToArrayTask<T> leftTask = new ToArrayTask<>(task, task.node.getChild(i), task.offset + size);
+                        K leftTask = task.makeChild(i, task.offset + size);
                         size += leftTask.node.count();
                         leftTask.fork();
                     }
-                    task = new ToArrayTask<>(task, task.node.getChild(i), task.offset + size);
+                    task = task.makeChild(i, task.offset + size);
                 }
             }
         }
+
+        private static final class OfRef<T> extends ToArrayTask<T, Node<T>, OfRef<T>> {
+            private final T[] array;
+
+            private OfRef(Node<T> node, T[] array, int offset) {
+                super(node, offset);
+                this.array = array;
+            }
+
+            private OfRef(OfRef<T> parent, Node<T> node, int offset) {
+                super(parent, node, offset);
+                this.array = parent.array;
+            }
+
+            @Override
+            OfRef<T> makeChild(int childIndex, int offset) {
+                return new OfRef<>(this, node.getChild(childIndex), offset);
+            }
+
+            @Override
+            void copyNodeToArray() {
+                node.copyInto(array, offset);
+            }
+        }
+
+        private static final class OfInt extends ToArrayTask<Integer, Node.OfInt, OfInt> {
+            private final int[] array;
+
+            private OfInt(Node.OfInt node, int[] array, int offset) {
+                super(node, offset);
+                this.array = array;
+            }
+
+            private OfInt(OfInt parent, Node.OfInt node, int offset) {
+                super(parent, node, offset);
+                this.array = parent.array;
+            }
+
+            @Override
+            OfInt makeChild(int childIndex, int offset) {
+                return new OfInt(this, node.getChild(childIndex), offset);
+            }
+
+            @Override
+            void copyNodeToArray() {
+                node.copyInto(array, offset);
+            }
+        }
+
+        private static final class OfLong extends ToArrayTask<Long, Node.OfLong, OfLong> {
+            private final long[] array;
+
+            private OfLong(Node.OfLong node, long[] array, int offset) {
+                super(node, offset);
+                this.array = array;
+            }
+
+            private OfLong(OfLong parent, Node.OfLong node, int offset) {
+                super(parent, node, offset);
+                this.array = parent.array;
+            }
+
+            @Override
+            OfLong makeChild(int childIndex, int offset) {
+                return new OfLong(this, node.getChild(childIndex), offset);
+            }
+
+            @Override
+            void copyNodeToArray() {
+                node.copyInto(array, offset);
+            }
+        }
+
+        private static final class OfDouble extends ToArrayTask<Double, Node.OfDouble, OfDouble> {
+            private final double[] array;
+
+            private OfDouble(Node.OfDouble node, double[] array, int offset) {
+                super(node, offset);
+                this.array = array;
+            }
+
+            private OfDouble(OfDouble parent, Node.OfDouble node, int offset) {
+                super(parent, node, offset);
+                this.array = parent.array;
+            }
+
+            @Override
+            OfDouble makeChild(int childIndex, int offset) {
+                return new OfDouble(this, node.getChild(childIndex), offset);
+            }
+
+            @Override
+            void copyNodeToArray() {
+                node.copyInto(array, offset);
+            }
+        }
     }
 
     // Int value implementations
 
-    // @@@ Note that the size collector task and to array task for references and
-    // primitives can unified with appropriate SAMs abstracting the details
-    // of push leaf data to an array or copying node data to an array at an offset.
-
     private static final class IntCollectorTask<T> extends AbstractTask<T, Integer, Node.OfInt, IntCollectorTask<T>> {
         private final PipelineHelper<Integer> helper;
 
@@ -603,7 +687,7 @@
 
         @Override
         protected Node.OfInt doLeaf() {
-            Node.Builder.OfInt builder = Nodes.intMakeBuilder(helper.exactOutputSizeIfKnown(spliterator));
+            Node.Builder.OfInt builder = Nodes.intBuilder(helper.exactOutputSizeIfKnown(spliterator));
             return helper.wrapAndCopyInto(builder, spliterator).build();
         }
 
@@ -618,58 +702,12 @@
                 for (IntCollectorTask<T> cur = children; cur != null; cur = cur.nextSibling)
                     nodes[idx++] = cur.getLocalResult();
 
-                setLocalResult(Nodes.intNode(nodes));
+                setLocalResult(Nodes.conc(nodes));
             }
             super.onCompletion(caller);
         }
     }
 
-    private static final class IntToArrayTask extends CountedCompleter<Void> {
-        private final int[] array;
-        private final Node.OfInt node;
-        private final int offset;
-
-        IntToArrayTask(Node.OfInt node, int[] array, int offset) {
-            this.array = array;
-            this.node = node;
-            this.offset = offset;
-        }
-
-        IntToArrayTask(IntToArrayTask parent, Node.OfInt node, int offset) {
-            super(parent);
-            this.array = parent.array;
-            this.node = node;
-            this.offset = offset;
-        }
-
-        @Override
-        public void compute() {
-            doCompute(this);
-        }
-
-        private static void doCompute(IntToArrayTask task) {
-            while (true) {
-                if (task.node.getChildCount() == 0) {
-                    task.node.copyInto(task.array, task.offset);
-                    task.propagateCompletion();
-                    return;
-                }
-                else {
-                    task.setPendingCount(task.node.getChildCount() - 1);
-
-                    int size = 0;
-                    int i = 0;
-                    for (;i < task.node.getChildCount() - 1; i++) {
-                        IntToArrayTask leftTask = new IntToArrayTask(task, task.node.getChild(i), task.offset + size);
-                        size += leftTask.node.count();
-                        leftTask.fork();
-                    }
-                    task = new IntToArrayTask(task, task.node.getChild(i), task.offset + size);
-                }
-            }
-        }
-    }
-
     // Long value implementations
 
     private static final class LongCollectorTask<T> extends AbstractTask<T, Long, Node.OfLong, LongCollectorTask<T>> {
@@ -692,7 +730,7 @@
 
         @Override
         protected Node.OfLong doLeaf() {
-            Node.Builder.OfLong builder = Nodes.longMakeBuilder(helper.exactOutputSizeIfKnown(spliterator));
+            Node.Builder.OfLong builder = Nodes.longBuilder(helper.exactOutputSizeIfKnown(spliterator));
             return helper.wrapAndCopyInto(builder, spliterator).build();
         }
 
@@ -707,58 +745,12 @@
                 for (LongCollectorTask<T> cur = children; cur != null; cur = cur.nextSibling)
                     nodes[idx++] = cur.getLocalResult();
 
-                setLocalResult(Nodes.longNode(nodes));
+                setLocalResult(Nodes.conc(nodes));
             }
             super.onCompletion(caller);
         }
     }
 
-    private static final class LongToArrayTask extends CountedCompleter<Void> {
-        private final long[] array;
-        private final Node.OfLong node;
-        private final int offset;
-
-        LongToArrayTask(Node.OfLong node, long[] array, int offset) {
-            this.array = array;
-            this.node = node;
-            this.offset = offset;
-        }
-
-        LongToArrayTask(LongToArrayTask parent, Node.OfLong node, int offset) {
-            super(parent);
-            this.array = parent.array;
-            this.node = node;
-            this.offset = offset;
-        }
-
-        @Override
-        public void compute() {
-            doCompute(this);
-        }
-
-        private static void doCompute(LongToArrayTask task) {
-            while (true) {
-                if (task.node.getChildCount() == 0) {
-                    task.node.copyInto(task.array, task.offset);
-                    task.propagateCompletion();
-                    return;
-                }
-                else {
-                    task.setPendingCount(task.node.getChildCount() - 1);
-
-                    int size = 0;
-                    int i = 0;
-                    for (;i < task.node.getChildCount() - 1; i++) {
-                        LongToArrayTask leftTask = new LongToArrayTask(task, task.node.getChild(i), task.offset + size);
-                        size += leftTask.node.count();
-                        leftTask.fork();
-                    }
-                    task = new LongToArrayTask(task, task.node.getChild(i), task.offset + size);
-                }
-            }
-        }
-    }
-
     // Double value implementations
 
     private static final class DoubleCollectorTask<T> extends AbstractTask<T, Double, Node.OfDouble, DoubleCollectorTask<T>> {
@@ -781,7 +773,7 @@
 
         @Override
         protected Node.OfDouble doLeaf() {
-            Node.Builder.OfDouble builder = Nodes.doubleMakeBuilder(helper.exactOutputSizeIfKnown(spliterator));
+            Node.Builder.OfDouble builder = Nodes.doubleBuilder(helper.exactOutputSizeIfKnown(spliterator));
             return helper.wrapAndCopyInto(builder, spliterator).build();
         }
 
@@ -796,56 +788,10 @@
                 for (DoubleCollectorTask<T> cur = children; cur != null; cur = cur.nextSibling)
                     nodes[idx++] = cur.getLocalResult();
 
-                setLocalResult(Nodes.doubleNode(nodes));
+                setLocalResult(Nodes.conc(nodes));
             }
             super.onCompletion(caller);
         }
     }
 
-    private static final class DoubleToArrayTask extends CountedCompleter<Void> {
-        private final double[] array;
-        private final Node.OfDouble node;
-        private final int offset;
-
-        DoubleToArrayTask(Node.OfDouble node, double[] array, int offset) {
-            this.array = array;
-            this.node = node;
-            this.offset = offset;
-        }
-
-        DoubleToArrayTask(DoubleToArrayTask parent, Node.OfDouble node, int offset) {
-            super(parent);
-            this.array = parent.array;
-            this.node = node;
-            this.offset = offset;
-        }
-
-        @Override
-        public void compute() {
-            doCompute(this);
-        }
-
-        private static void doCompute(DoubleToArrayTask task) {
-            while (true) {
-                if (task.node.getChildCount() == 0) {
-                    task.node.copyInto(task.array, task.offset);
-                    task.propagateCompletion();
-                    return;
-                }
-                else {
-                    task.setPendingCount(task.node.getChildCount() - 1);
-
-                    int size = 0;
-                    int i = 0;
-                    for (;i < task.node.getChildCount() - 1; i++) {
-                        DoubleToArrayTask leftTask = new DoubleToArrayTask(task, task.node.getChild(i), task.offset + size);
-                        size += leftTask.node.count();
-                        leftTask.fork();
-                    }
-                    task = new DoubleToArrayTask(task, task.node.getChild(i), task.offset + size);
-                }
-            }
-        }
-    }
-
 }
--- a/src/share/classes/java/util/stream/Nodes.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/src/share/classes/java/util/stream/Nodes.java	Fri Apr 12 12:56:52 2013 -0400
@@ -91,17 +91,17 @@
      * are an not instance of type supported by this factory.
      */
     @SuppressWarnings("unchecked")
-    static <T> Node<T> createConcNode(StreamShape shape, List<Node<T>> nodes) {
+    static <T> Node<T> conc(StreamShape shape, List<Node<T>> nodes) {
         try {
             switch (shape) {
                 case REFERENCE:
                     return node(nodes.toArray(new Node[nodes.size()]));
                 case INT_VALUE:
-                    return (Node<T>) intNode(nodes.toArray(new Node.OfInt[nodes.size()]));
+                    return (Node<T>) conc(nodes.toArray(new Node.OfInt[nodes.size()]));
                 case LONG_VALUE:
-                    return (Node<T>) longNode(nodes.toArray(new Node.OfLong[nodes.size()]));
+                    return (Node<T>) conc(nodes.toArray(new Node.OfLong[nodes.size()]));
                 case DOUBLE_VALUE:
-                    return (Node<T>) doubleNode(nodes.toArray(new Node.OfDouble[nodes.size()]));
+                    return (Node<T>) conc(nodes.toArray(new Node.OfDouble[nodes.size()]));
                 default:
                     throw new IllegalStateException("Unknown shape " + shape);
             }
@@ -135,7 +135,7 @@
         switch (shape) {
             case REFERENCE: {
                 Spliterator<T> spliterator = input.spliterator();
-                Node.Builder<T> nodeBuilder = Nodes.makeBuilder(size, generator);
+                Node.Builder<T> nodeBuilder = Nodes.builder(size, generator);
                 nodeBuilder.begin(size);
                 for (int i = 0; i < from && spliterator.tryAdvance(e -> { }); i++) { }
                 for (int i = 0; (i < size) && spliterator.tryAdvance(nodeBuilder); i++) { }
@@ -144,7 +144,7 @@
             }
             case INT_VALUE: {
                 Spliterator.OfInt spliterator = ((Node.OfInt) input).spliterator();
-                Node.Builder.OfInt nodeBuilder = Nodes.intMakeBuilder(size);
+                Node.Builder.OfInt nodeBuilder = Nodes.intBuilder(size);
                 nodeBuilder.begin(size);
                 for (int i = 0; i < from && spliterator.tryAdvance((IntConsumer) e -> { }); i++) { }
                 for (int i = 0; (i < size) && spliterator.tryAdvance((IntConsumer) nodeBuilder); i++) { }
@@ -153,7 +153,7 @@
             }
             case LONG_VALUE: {
                 Spliterator.OfLong spliterator = ((Node.OfLong) input).spliterator();
-                Node.Builder.OfLong nodeBuilder = Nodes.longMakeBuilder(size);
+                Node.Builder.OfLong nodeBuilder = Nodes.longBuilder(size);
                 nodeBuilder.begin(size);
                 for (int i = 0; i < from && spliterator.tryAdvance((LongConsumer) e -> { }); i++) { }
                 for (int i = 0; (i < size) && spliterator.tryAdvance((LongConsumer) nodeBuilder); i++) { }
@@ -162,7 +162,7 @@
             }
             case DOUBLE_VALUE: {
                 Spliterator.OfDouble spliterator = ((Node.OfDouble) input).spliterator();
-                Node.Builder.OfDouble nodeBuilder = Nodes.doubleMakeBuilder(size);
+                Node.Builder.OfDouble nodeBuilder = Nodes.doubleBuilder(size);
                 nodeBuilder.begin(size);
                 for (int i = 0; i < from && spliterator.tryAdvance((DoubleConsumer) e -> { }); i++) { }
                 for (int i = 0; (i < size) && spliterator.tryAdvance((DoubleConsumer) nodeBuilder); i++) { }
@@ -250,10 +250,10 @@
      * @param <T> the type of elements of the node builder
      * @return a {@code Node.Builder}
      */
-    static <T> Node.Builder<T> makeBuilder(long exactSizeIfKnown, IntFunction<T[]> generator) {
+    static <T> Node.Builder<T> builder(long exactSizeIfKnown, IntFunction<T[]> generator) {
         return (exactSizeIfKnown >= 0 && exactSizeIfKnown < Streams.MAX_ARRAY_SIZE)
                ? new FixedNodeBuilder<>(exactSizeIfKnown, generator)
-               : makeBuilder();
+               : builder();
     }
 
     /**
@@ -262,7 +262,7 @@
      * @param <T> the type of elements of the node builder
      * @return a {@code Node.Builder}
      */
-    static <T> Node.Builder<T> makeBuilder() {
+    static <T> Node.Builder<T> builder() {
         return new SpinedNodeBuilder<>();
     }
 
@@ -276,7 +276,7 @@
      * @param array the array
      * @return a node holding an array
      */
-    static Node.OfInt intNode(int[] array) {
+    static Node.OfInt node(int[] array) {
         return new IntArrayNode(array);
     }
 
@@ -295,7 +295,7 @@
      * @return a {@code Node.OfInt} covering the elements of the input nodes
      */
     @SafeVarargs
-    static Node.OfInt intNode(Node.OfInt... nodes) {
+    static Node.OfInt conc(Node.OfInt... nodes) {
         Objects.requireNonNull(nodes);
         if (nodes.length > 1) {
             return new IntConcNode(nodes);
@@ -316,10 +316,10 @@
      * fail if the wrong number of elements are added to the builder.
      * @return a {@code Node.Builder.OfInt}
      */
-    static Node.Builder.OfInt intMakeBuilder(long exactSizeIfKnown) {
+    static Node.Builder.OfInt intBuilder(long exactSizeIfKnown) {
         return (exactSizeIfKnown >= 0 && exactSizeIfKnown < Streams.MAX_ARRAY_SIZE)
                ? new IntFixedNodeBuilder(exactSizeIfKnown)
-               : intMakeBuilder();
+               : intBuilder();
     }
 
     /**
@@ -327,7 +327,7 @@
      *
      * @return a {@code Node.Builder.OfInt}
      */
-    static Node.Builder.OfInt intMakeBuilder() {
+    static Node.Builder.OfInt intBuilder() {
         return new IntSpinedNodeBuilder();
     }
 
@@ -341,7 +341,7 @@
      * @param array the array
      * @return a node holding an array
      */
-    static Node.OfLong longNode(final long[] array) {
+    static Node.OfLong node(final long[] array) {
         return new LongArrayNode(array);
     }
 
@@ -360,7 +360,7 @@
      * @return a {@code Node.OfLong} covering the elements of the input nodes
      */
     @SafeVarargs
-    static Node.OfLong longNode(Node.OfLong... nodes) {
+    static Node.OfLong conc(Node.OfLong... nodes) {
         Objects.requireNonNull(nodes);
         if (nodes.length > 1) {
             return new LongConcNode(nodes);
@@ -381,10 +381,10 @@
      * fail if the wrong number of elements are added to the builder.
      * @return a {@code Node.Builder.OfLong}
      */
-    static Node.Builder.OfLong longMakeBuilder(long exactSizeIfKnown) {
+    static Node.Builder.OfLong longBuilder(long exactSizeIfKnown) {
         return (exactSizeIfKnown >= 0 && exactSizeIfKnown < Streams.MAX_ARRAY_SIZE)
                ? new LongFixedNodeBuilder(exactSizeIfKnown)
-               : longMakeBuilder();
+               : longBuilder();
     }
 
     /**
@@ -392,7 +392,7 @@
      *
      * @return a {@code Node.Builder.OfLong}
      */
-    static Node.Builder.OfLong longMakeBuilder() {
+    static Node.Builder.OfLong longBuilder() {
         return new LongSpinedNodeBuilder();
     }
 
@@ -406,7 +406,7 @@
      * @param array the array
      * @return a node holding an array
      */
-    static Node.OfDouble doubleNode(final double[] array) {
+    static Node.OfDouble node(final double[] array) {
         return new DoubleArrayNode(array);
     }
 
@@ -425,7 +425,7 @@
      * @return a {@code Node.ofDouble} covering the elements of the input nodes
      */
     @SafeVarargs
-    static Node.OfDouble doubleNode(Node.OfDouble... nodes) {
+    static Node.OfDouble conc(Node.OfDouble... nodes) {
         Objects.requireNonNull(nodes);
         if (nodes.length > 1) {
             return new DoubleConcNode(nodes);
@@ -446,10 +446,10 @@
      * fail if the wrong number of elements are added to the builder.
      * @return a {@code Node.Builder.OfDouble}
      */
-    static Node.Builder.OfDouble doubleMakeBuilder(long exactSizeIfKnown) {
+    static Node.Builder.OfDouble doubleBuilder(long exactSizeIfKnown) {
         return (exactSizeIfKnown >= 0 && exactSizeIfKnown < Streams.MAX_ARRAY_SIZE)
                ? new DoubleFixedNodeBuilder(exactSizeIfKnown)
-               : doubleMakeBuilder();
+               : doubleBuilder();
     }
 
     /**
@@ -457,7 +457,7 @@
      *
      * @return a {@code Node.Builder.OfDouble}
      */
-    static Node.Builder.OfDouble doubleMakeBuilder() {
+    static Node.Builder.OfDouble doubleBuilder() {
         return new DoubleSpinedNodeBuilder();
     }
 
--- a/src/share/classes/java/util/stream/ReferencePipeline.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/src/share/classes/java/util/stream/ReferencePipeline.java	Fri Apr 12 12:56:52 2013 -0400
@@ -127,7 +127,7 @@
 
     @Override
     final Node.Builder<U> makeNodeBuilder(long exactSizeIfKnown, IntFunction<U[]> generator) {
-        return Nodes.makeBuilder(exactSizeIfKnown, generator);
+        return Nodes.builder(exactSizeIfKnown, generator);
     }
 
 
--- a/src/share/classes/java/util/stream/SliceOps.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/src/share/classes/java/util/stream/SliceOps.java	Fri Apr 12 12:56:52 2013 -0400
@@ -346,7 +346,7 @@
                     else
                         // This will create a tree of depth 1 and will not be a sub-tree
                         // for leaf nodes within the require range
-                        result = Nodes.createConcNode(op.getOutputShape(), nodes);
+                        result = Nodes.conc(op.getOutputShape(), nodes);
                     setLocalResult(result);
                 }
             }
--- a/src/share/classes/java/util/stream/SortedOps.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/src/share/classes/java/util/stream/SortedOps.java	Fri Apr 12 12:56:52 2013 -0400
@@ -189,7 +189,7 @@
                 int[] content = n.asIntArray();
                 Arrays.parallelSort(content);
 
-                return Nodes.intNode(content);
+                return Nodes.node(content);
             }
         }
     }
@@ -226,7 +226,7 @@
                 long[] content = n.asLongArray();
                 Arrays.parallelSort(content);
 
-                return Nodes.longNode(content);
+                return Nodes.node(content);
             }
         }
     }
@@ -263,7 +263,7 @@
                 double[] content = n.asDoubleArray();
                 Arrays.parallelSort(content);
 
-                return Nodes.doubleNode(content);
+                return Nodes.node(content);
             }
         }
     }
--- a/test-ng/boottests/java/util/stream/DoubleNodeTest.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/test-ng/boottests/java/util/stream/DoubleNodeTest.java	Fri Apr 12 12:56:52 2013 -0400
@@ -49,11 +49,11 @@
 
             List<Node<Double>> nodes = new ArrayList<>();
 
-            nodes.add(Nodes.doubleNode(array));
+            nodes.add(Nodes.node(array));
             nodes.add(degenerateTree(Spliterators.iteratorFromSpliterator(Arrays.spliterator(array))));
-            nodes.add(tree(toList(array), l -> Nodes.doubleNode(toDoubleArray(l))));
-            nodes.add(fill(array, Nodes.doubleMakeBuilder(array.length)));
-            nodes.add(fill(array, Nodes.doubleMakeBuilder()));
+            nodes.add(tree(toList(array), l -> Nodes.node(toDoubleArray(l))));
+            nodes.add(fill(array, Nodes.doubleBuilder(array.length)));
+            nodes.add(fill(array, Nodes.doubleBuilder()));
 
             for (Node<Double> node : nodes) {
                 params.add(new Object[]{array, node});
@@ -99,15 +99,15 @@
 
     private Node.OfDouble degenerateTree(PrimitiveIterator.OfDouble it) {
         if (!it.hasNext()) {
-            return Nodes.doubleNode(new double[0]);
+            return Nodes.node(new double[0]);
         }
 
         double i = it.nextDouble();
         if (it.hasNext()) {
-            return Nodes.doubleNode(Nodes.doubleNode(new double[]{i}), degenerateTree(it));
+            return Nodes.conc(Nodes.node(new double[] {i}), degenerateTree(it));
         }
         else {
-            return Nodes.doubleNode(new double[]{i});
+            return Nodes.node(new double[] {i});
         }
     }
 
@@ -116,7 +116,7 @@
             return m.apply(l);
         }
         else {
-            return Nodes.doubleNode(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
+            return Nodes.conc(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
         }
     }
 
@@ -127,7 +127,7 @@
 
     @Test(dataProvider = "nodes")
     public void testFlattenAsArray(double[] array, Node.OfDouble n) {
-        assertEquals(NodeUtils.doubleFlatten(n).asDoubleArray(), array);
+        assertEquals(NodeUtils.flattenDouble(n).asDoubleArray(), array);
     }
 
     @Test(dataProvider = "nodes")
--- a/test-ng/boottests/java/util/stream/IntNodeTest.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/test-ng/boottests/java/util/stream/IntNodeTest.java	Fri Apr 12 12:56:52 2013 -0400
@@ -49,11 +49,11 @@
 
             List<Node<Integer>> nodes = new ArrayList<>();
 
-            nodes.add(Nodes.intNode(array));
+            nodes.add(Nodes.node(array));
             nodes.add(degenerateTree(Spliterators.iteratorFromSpliterator(Arrays.spliterator(array))));
-            nodes.add(tree(toList(array), l -> Nodes.intNode(toIntArray(l))));
-            nodes.add(fill(array, Nodes.intMakeBuilder(array.length)));
-            nodes.add(fill(array, Nodes.intMakeBuilder()));
+            nodes.add(tree(toList(array), l -> Nodes.node(toIntArray(l))));
+            nodes.add(fill(array, Nodes.intBuilder(array.length)));
+            nodes.add(fill(array, Nodes.intBuilder()));
 
             for (Node<Integer> node : nodes) {
                 params.add(new Object[]{array, node});
@@ -99,15 +99,15 @@
 
     private Node.OfInt degenerateTree(PrimitiveIterator.OfInt it) {
         if (!it.hasNext()) {
-            return Nodes.intNode(new int[0]);
+            return Nodes.node(new int[0]);
         }
 
         int i = it.nextInt();
         if (it.hasNext()) {
-            return Nodes.intNode(Nodes.intNode(new int[]{i}), degenerateTree(it));
+            return Nodes.conc(Nodes.node(new int[] {i}), degenerateTree(it));
         }
         else {
-            return Nodes.intNode(new int[]{i});
+            return Nodes.node(new int[] {i});
         }
     }
 
@@ -116,7 +116,7 @@
             return m.apply(l);
         }
         else {
-            return Nodes.intNode(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
+            return Nodes.conc(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
         }
     }
 
@@ -127,7 +127,7 @@
 
     @Test(dataProvider = "nodes")
     public void testFlattenAsArray(int[] array, Node.OfInt n) {
-        assertEquals(NodeUtils.intFlatten(n).asIntArray(), array);
+        assertEquals(NodeUtils.flattenInt(n).asIntArray(), array);
     }
 
     @Test(dataProvider = "nodes")
--- a/test-ng/boottests/java/util/stream/LongNodeTest.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/test-ng/boottests/java/util/stream/LongNodeTest.java	Fri Apr 12 12:56:52 2013 -0400
@@ -49,11 +49,11 @@
 
             List<Node<Long>> nodes = new ArrayList<>();
 
-            nodes.add(Nodes.longNode(array));
+            nodes.add(Nodes.node(array));
             nodes.add(degenerateTree(Spliterators.iteratorFromSpliterator(Arrays.spliterator(array))));
-            nodes.add(tree(toList(array), l -> Nodes.longNode(toLongArray(l))));
-            nodes.add(fill(array, Nodes.longMakeBuilder(array.length)));
-            nodes.add(fill(array, Nodes.longMakeBuilder()));
+            nodes.add(tree(toList(array), l -> Nodes.node(toLongArray(l))));
+            nodes.add(fill(array, Nodes.longBuilder(array.length)));
+            nodes.add(fill(array, Nodes.longBuilder()));
 
             for (Node<Long> node : nodes) {
                 params.add(new Object[]{array, node});
@@ -99,15 +99,15 @@
 
     private Node.OfLong degenerateTree(PrimitiveIterator.OfLong it) {
         if (!it.hasNext()) {
-            return Nodes.longNode(new long[0]);
+            return Nodes.node(new long[0]);
         }
 
         long i = it.nextLong();
         if (it.hasNext()) {
-            return Nodes.longNode(Nodes.longNode(new long[]{i}), degenerateTree(it));
+            return Nodes.conc(Nodes.node(new long[] {i}), degenerateTree(it));
         }
         else {
-            return Nodes.longNode(new long[]{i});
+            return Nodes.node(new long[] {i});
         }
     }
 
@@ -116,7 +116,7 @@
             return m.apply(l);
         }
         else {
-            return Nodes.longNode(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
+            return Nodes.conc(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
         }
     }
 
@@ -127,7 +127,7 @@
 
     @Test(dataProvider = "nodes")
     public void testFlattenAsArray(long[] array, Node.OfLong n) {
-        assertEquals(NodeUtils.longFlatten(n).asLongArray(), array);
+        assertEquals(NodeUtils.flattenLong(n).asLongArray(), array);
     }
 
     @Test(dataProvider = "nodes")
--- a/test-ng/boottests/java/util/stream/NodeBuilderTest.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/test-ng/boottests/java/util/stream/NodeBuilderTest.java	Fri Apr 12 12:56:52 2013 -0400
@@ -55,8 +55,8 @@
         }
 
         List<Function<Integer, Node.Builder<Integer>>> ms = Arrays.asList(
-                s -> Nodes.makeBuilder(),
-                s -> Nodes.makeBuilder(s, LambdaTestHelpers.integerArrayGenerator)
+                s -> Nodes.builder(),
+                s -> Nodes.builder(s, LambdaTestHelpers.integerArrayGenerator)
         );
 
         Object[][] params = new Object[ls.size() * ms.size()][];
@@ -100,8 +100,8 @@
         }
 
         List<Function<Integer, Node.Builder<Integer>>> ms = Arrays.asList(
-                s -> Nodes.intMakeBuilder(),
-                s -> Nodes.intMakeBuilder(s)
+                s -> Nodes.intBuilder(),
+                s -> Nodes.intBuilder(s)
         );
 
         Object[][] params = new Object[ls.size() * ms.size()][];
@@ -149,8 +149,8 @@
         }
 
         List<Function<Integer, Node.Builder<Long>>> ms = Arrays.asList(
-                s -> Nodes.longMakeBuilder(),
-                s -> Nodes.longMakeBuilder(s)
+                s -> Nodes.longBuilder(),
+                s -> Nodes.longBuilder(s)
         );
 
         Object[][] params = new Object[ls.size() * ms.size()][];
@@ -198,8 +198,8 @@
         }
 
         List<Function<Integer, Node.Builder<Double>>> ms = Arrays.asList(
-                s -> Nodes.doubleMakeBuilder(),
-                s -> Nodes.doubleMakeBuilder(s)
+                s -> Nodes.doubleBuilder(),
+                s -> Nodes.doubleBuilder(s)
         );
 
         Object[][] params = new Object[ls.size() * ms.size()][];
--- a/test-ng/boottests/java/util/stream/NodeTest.java	Fri Apr 12 17:22:49 2013 +0200
+++ b/test-ng/boottests/java/util/stream/NodeTest.java	Fri Apr 12 12:56:52 2013 -0400
@@ -53,8 +53,8 @@
             nodes.add(degenerateTree(Arrays.asList(array).iterator()));
             nodes.add(tree(Arrays.asList(array), l -> Nodes.node(l.toArray(new Integer[l.size()]))));
             nodes.add(tree(Arrays.asList(array), l -> Nodes.node(l)));
-            nodes.add(fill(array, Nodes.makeBuilder(array.length, LambdaTestHelpers.integerArrayGenerator)));
-            nodes.add(fill(array, Nodes.makeBuilder()));
+            nodes.add(fill(array, Nodes.builder(array.length, LambdaTestHelpers.integerArrayGenerator)));
+            nodes.add(fill(array, Nodes.builder()));
 
             for (int i = 0; i < nodes.size(); i++) {
                 params.add(new Object[]{array, nodes.get(i)});
@@ -81,7 +81,7 @@
 
         Integer i = it.next();
         if (it.hasNext()) {
-            return Nodes.node(Nodes.node(new Integer[]{i}), degenerateTree(it));
+            return Nodes.node(Nodes.node(new Integer[] {i}), degenerateTree(it));
         }
         else {
             return Nodes.node(new Integer[]{i});