jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [11/12] jena git commit: From review of Tuple PR
Date Tue, 29 Dec 2015 21:23:32 GMT
>From review of Tuple PR


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/9b5aec9c
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/9b5aec9c
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/9b5aec9c

Branch: refs/heads/master
Commit: 9b5aec9c38110069cd2f33cdd0d7866e952902bb
Parents: 068113e
Author: Andy Seaborne <andy@seaborne.org>
Authored: Tue Dec 29 21:19:21 2015 +0000
Committer: Andy Seaborne <andy@seaborne.org>
Committed: Tue Dec 29 21:19:21 2015 +0000

----------------------------------------------------------------------
 .../org/apache/jena/atlas/lib/tuple/Tuple.java  | 27 +++++++++++++++-----
 .../apache/jena/atlas/lib/tuple/TupleBase.java  | 13 ----------
 2 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/9b5aec9c/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/Tuple.java
----------------------------------------------------------------------
diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/Tuple.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/Tuple.java
index e3aa7e3..016e878d 100644
--- a/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/Tuple.java
+++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/Tuple.java
@@ -18,13 +18,17 @@
 
 package org.apache.jena.atlas.lib.tuple;
 
+import java.util.Iterator ;
 import java.util.List ;
 import java.util.function.Consumer ;
 import java.util.stream.Stream ;
+import java.util.stream.StreamSupport ;
 
 import org.apache.jena.atlas.lib.ArrayUtils ;
 
-/** A Tuple is the same class of item */
+/** A Tuple is a sequence of items of the same class of item.
+ *  Tuples are immutable.  .equals is "by value".
+ */
 public interface Tuple<X> extends Iterable<X> {
     /** Get the i'th element, for i in the range 0 to len()-1 
      * @throws IndexOutOfBoundsException for i out of range 
@@ -41,7 +45,7 @@ public interface Tuple<X> extends Iterable<X> {
 
     /** stream */
     public default Stream<X> stream() { 
-        return asList().stream() ;
+        return StreamSupport.stream(spliterator(), false) ;
     }
 
     /** forEach */
@@ -50,20 +54,29 @@ public interface Tuple<X> extends Iterable<X> {
         asList().forEach(action) ;
     }
 
-    /** Copy the Tuple into the array */ 
+    /** Iterable */
+    @Override
+    public default Iterator<X> iterator() {
+        return asList().iterator() ;
+    }
+
+    /** Copy the elements of this Tuple into the array */ 
     public default void copyInto(X[] array) {
         copyInto(array, 0, len());
     }
 
-    /** Copy the Tuple into the array */ 
+    /** Copy the elements of this Tuple into the array */ 
     public default void copyInto(X[] array, int start) {
         copyInto(array, start, len());
     }
 
-    /** Copy the Tuple into the array */ 
-    public void copyInto(X[] array, int start, int length) ;
+    /** Copy the elements of this Tuple into the array */ 
+    public default void copyInto(X[] array, int start, int length) {
+        for ( int i = 0 ; i < Math.min(length, len()) ; i++ )
+            array[i+start] = get(i) ;
+    }
 
-    /** Copy the Tuple into the array */ 
+    /** Copy the elements of this Tuple into a newly created array */ 
     public default X[] asArray(Class<X> cls) {
         X[] elts = ArrayUtils.alloc(cls, len()) ;
         for ( int i = 0 ; i < len() ; i++ )

http://git-wip-us.apache.org/repos/asf/jena/blob/9b5aec9c/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/TupleBase.java
----------------------------------------------------------------------
diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/TupleBase.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/TupleBase.java
index 6e174ac..90cdbf3 100644
--- a/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/TupleBase.java
+++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/tuple/TupleBase.java
@@ -18,24 +18,11 @@
 
 package org.apache.jena.atlas.lib.tuple;
 
-import java.util.Iterator ;
 import java.util.Objects ;
 
 abstract class TupleBase<X> implements Tuple<X> {
     protected TupleBase() {}
 
-    /** Iterable */
-    @Override
-    public Iterator<X> iterator() {
-        return asList().iterator() ;
-    }
-
-    @Override
-    public void copyInto(X[] array, int start, int length) {
-        for ( int i = 0 ; i < Math.min(length, len()) ; i++ )
-            array[i+start] = get(i) ;
-    }
-
     @Override
     public final
     int hashCode() {


Mime
View raw message