Class BasicIter<I extends Item>

java.lang.Object
org.basex.query.iter.Iter
org.basex.query.iter.BasicIter<I>
Type Parameters:
I - generic item type
All Implemented Interfaces:
Iterable<I>

public abstract class BasicIter<I extends Item> extends Iter implements Iterable<I>
Basic iterator, throwing no exceptions. This class also implements the Iterable interface. Hence, all values can also be retrieved via an enhanced for-loop. Using next() is faster.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
    Current position.
    protected final long
    Result size.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BasicIter(long size)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract I
    get(long i)
    Returns the specified item, or an arbitrary item if the index is invalid.
    final Iterator<I>
     
    Returns the next item.
    final long
    Returns the iterator size.

    Methods inherited from class org.basex.query.iter.Iter

    iterValue, value

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • size

      protected final long size
      Result size.
    • pos

      protected long pos
      Current position.
  • Constructor Details

    • BasicIter

      protected BasicIter(long size)
      Constructor.
      Parameters:
      size - size
  • Method Details

    • get

      public abstract I get(long i)
      Description copied from class: Iter
      Returns the specified item, or an arbitrary item if the index is invalid. If this method returns items, Iter.size() needs to be implemented as well.
      Overrides:
      get in class Iter
      Parameters:
      i - value offset (starting with 0)
      Returns:
      specified item or null
    • next

      public I next()
      Description copied from class: Iter
      Returns the next item.
      Specified by:
      next in class Iter
      Returns:
      resulting item, or null if all items have been returned
    • size

      public final long size()
      Description copied from class: Iter
      Returns the iterator size. -1 is returned if the result size is unknown. If this method returns a positive value, Iter.get(long) needs to be implemented as well.
      Overrides:
      size in class Iter
      Returns:
      number of entries
    • iterator

      public final Iterator<I> iterator()
      Specified by:
      iterator in interface Iterable<I extends Item>