All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.epfl.labos.iu.orm.LazyIterator Maven / Gradle / Ivy

Go to download

Jinq public API for extending Java 8 streams with database functionality

There is a newer version: 2.0.2
Show newest version
/**
 * 
 */
package ch.epfl.labos.iu.orm;

import java.util.Iterator;

public class LazyIterator implements Iterator
{
   public LazySet parent;
   LazyIterator(LazySet parent)
   {
      this.parent = parent;
   }
   Iterator realIterator = null;
   public boolean hasNext()
   {
      if (realIterator == null)
      {
         parent.realize();
         realIterator = parent.data.iterator();
      }
      return realIterator.hasNext();
   }

   public T next()
   {
      if (realIterator == null)
      {
         parent.realize();
         realIterator = parent.data.iterator();
      }
      return realIterator.next();
   }

   public void remove()
   {
      if (realIterator == null)
      {
         parent.realize();
         realIterator = parent.data.iterator();
      }
      realIterator.remove();
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy