Class IteratorEnumeratorFacade<E>

java.lang.Object
org.jhotdraw8.collection.enumerator.IteratorEnumeratorFacade<E>
Type Parameters:
E - the element type
All Implemented Interfaces:
Spliterator<E>, BareEnumerator<E>, Enumerator<E>

public class IteratorEnumeratorFacade<E> extends Object implements Enumerator<E>
Provides a Enumerator facade for an Iterator.
Author:
Werner Randelshofer
  • Constructor Details

    • IteratorEnumeratorFacade

      public IteratorEnumeratorFacade(@NonNull Iterator<? extends E> iterator)
  • Method Details

    • moveNext

      public boolean moveNext()
      Description copied from interface: BareEnumerator
      Advances the enumerator to the next element of the collection.
      Specified by:
      moveNext in interface BareEnumerator<E>
      Returns:
      true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
    • current

      public E current()
      Description copied from interface: BareEnumerator
      Gets the element in the collection at the current position of the enumerator.

      Current is undefined under any of the following conditions:

      • The enumerator is positioned before the first element in the collection. Immediately after the enumerator is created BareEnumerator.moveNext() must be called to advance the enumerator to the first element of the collection before reading the value of Current.
      • The last call to BareEnumerator.moveNext() returned false, which indicates the end of the collection.
      • The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements.
      Current returns the same object until MoveNext is called.MoveNext sets Current to the next element.
      Specified by:
      current in interface BareEnumerator<E>
      Returns:
      current
    • trySplit

      public @Nullable Spliterator<E> trySplit()
      Specified by:
      trySplit in interface Spliterator<E>
    • estimateSize

      public long estimateSize()
      Specified by:
      estimateSize in interface Spliterator<E>
    • characteristics

      public int characteristics()
      Specified by:
      characteristics in interface Spliterator<E>