jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1446312 - in /jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator: Iter.java SingletonIterator.java
Date Thu, 14 Feb 2013 20:03:36 GMT
Author: andy
Date: Thu Feb 14 20:03:36 2013
New Revision: 1446312

URL: http://svn.apache.org/r1446312
Log:
Clean up: Put iter operations for creation together; remove Iterable from SingletonIterator.

Modified:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/Iter.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/SingletonIterator.java

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/Iter.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/Iter.java?rev=1446312&r1=1446311&r2=1446312&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/Iter.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/Iter.java Thu Feb 14
20:03:36 2013
@@ -603,6 +603,12 @@ public class Iter<T> implements Iterable
     // May not do what you expect. iter(int[]) is iter of one object (an int[])
 //    public static <T> Iter<T> iter(T...objects)
 //    { return Iter.iter(Arrays.asList(objects)) ; }
+
+    public static <T> Iter<T> iterSingleton(T x)
+    {
+        return Iter.iter(SingletonIterator.create(x)) ;
+    }
+
     
     public static <T> Iter<T> iter(Collection<T> collection)
     {
@@ -623,7 +629,24 @@ public class Iter<T> implements Iterable
         return new Iter<T>(iterable.iterator()) ;
     }
     
-    /** Materializae an iterator, that is, force it to run now - useful in debugging */ 
+    //----
+    // Iter class part
+    // And ....
+    // Could merge in concatenated iterators - if used a lot there is reducable cost.
+    // Just putting in a slot is free (?) because objects of one or two slots have
+    // the same memory allocation.
+    // And .. be an iterator framework for extension
+    
+    // Or dynamically with a subclass and a static constructor
+    // List<Iterator> concatenated = null ; 
+    
+    public static <T> Iter<T> singletonIter(T item)
+    { return new Iter<T>(new SingletonIterator<T>(item)) ; }
+
+    public static <T> Iter<T> nullIter()
+    { return new Iter<T>(new NullIterator<T>()) ; }
+
+    /** Materialize an iterator, that is, force it to run now - useful in debugging */ 
     public static <T> Iterator<T> materialize(Iterator<T> iter)
     {
         return Iter.toList(iter).iterator() ;
@@ -834,21 +857,4 @@ public class Iter<T> implements Iterable
 
     @Override
     public void remove()        { iterator.remove() ; }
-
-    //----
-    // Iter class part
-    // And ....
-    // Could merge in concatenated iterators - if used a lot there is reducable cost.
-    // Just putting in a slot is free (?) because objects of one or two slots have
-    // the same memory allocation.
-    // And .. be an iterator framework for extension
-    
-    // Or dynamically with a subclass and a static constructor
-    // List<Iterator> concatenated = null ; 
-    
-    public static <T> Iter<T> singletonIter(T item)
-    { return new Iter<T>(new SingletonIterator<T>(item)) ; }
-
-    public static <T> Iter<T> nullIter()
-    { return new Iter<T>(new NullIterator<T>()) ; }
 }

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/SingletonIterator.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/SingletonIterator.java?rev=1446312&r1=1446311&r2=1446312&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/SingletonIterator.java
(original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/atlas/iterator/SingletonIterator.java
Thu Feb 14 20:03:36 2013
@@ -21,7 +21,7 @@ package org.apache.jena.atlas.iterator;
 import java.util.Iterator ;
 import java.util.NoSuchElementException ;
 
-public class SingletonIterator<T> implements Iterator<T>, Iterable<T>
+public class SingletonIterator<T> implements Iterator<T>
 {
     private T thing = null ;
     private boolean yielded = false ;
@@ -49,10 +49,10 @@ public class SingletonIterator<T> implem
     public void remove()
     { throw new NoSuchElementException("SingletonIterator.remove") ;}
 
-    @Override
-    public Iterator<T> iterator()
-    {
-        return this ;
-    }
+//    @Override
+//    public Iterator<T> iterator()
+//    {
+//        return this ;
+//    }
 
 }



Mime
View raw message