Class ProgressIterator<V>

java.lang.Object
com.sk89q.worldedit.util.task.progress.ProgressIterator<V>
Type Parameters:
V - the type
All Implemented Interfaces:
ProgressObservable, Iterator<V>

public class ProgressIterator<V> extends Object implements Iterator<V>, ProgressObservable
An iterator that keeps track of how many entries have been visited and calculates a "percent completed" using a provided total count.

The returned progress percentage will always be between 0 or 1 (inclusive). If the iterator returns more entries than the total count, then 100% will be returned for the progress.

  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<V>
    • next

      public V next()
      Specified by:
      next in interface Iterator<V>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<V>
    • getProgress

      public Progress getProgress()
      Description copied from interface: ProgressObservable
      Get the current percentage of completion.
      Specified by:
      getProgress in interface ProgressObservable
      Returns:
      a progress object
    • create

      public static <V> ProgressIterator<V> create(Iterator<V> iterator, int count)
      Create a new instance.
      Type Parameters:
      V - the type
      Parameters:
      iterator - the iterator
      count - the number of objects
      Returns:
      an instance
    • create

      public static <V> ProgressIterator<V> create(List<V> list)
      Create a new instance from a list.
      Type Parameters:
      V - the type
      Parameters:
      list - a list
      Returns:
      an instance