Class CyclicIterator<T>

  • All Implemented Interfaces:
    java.util.Iterator<T>

    @ThreadSafe
    public class CyclicIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>
    Cyclic iterator iterates over the list provided, and once the list is over it starts from the beginning till the iteration is stopped by calling stop() to do so, explicitly. The iterator is used as generator for the load generator system.

    Version:
    1.0.0
    Author:
    Erhan Bagdemir
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      The method returns a boolean value indicating whether the iterator has more items.
      T next()
      Returns the next item where the cursor points to.
      void stop()
      Sets the hasNext attribute to false.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
    • Constructor Detail

      • CyclicIterator

        public CyclicIterator​(java.util.List<T> list)
        Creates a new CyclicIterator instance.

        Parameters:
        list - The list backing the iterator.
    • Method Detail

      • hasNext

        public boolean hasNext()
        The method returns a boolean value indicating whether the iterator has more items.

        Specified by:
        hasNext in interface java.util.Iterator<T>
        Returns:
        boolean, whether the iterator has more items.
      • next

        public T next()
        Returns the next item where the cursor points to. Calling this method sets the cursor forward to point the next item in the list. If the cursor is at the end of the list, it begins from the first item.

        Specified by:
        next in interface java.util.Iterator<T>
        Returns:
        The current item, pointed by the cursor.
      • stop

        public void stop()
        Sets the hasNext attribute to false. Every next method call after stop causes a NoSuchElementException.