Class Iterators

java.lang.Object
io.atlassian.fugue.Iterators

class Iterators extends Object
Utility class for constructing iterables
Since:
3.0
  • Constructor Details

    • Iterators

      Iterators()
  • Method Details

    • addAll

      static <A> boolean addAll(Collection<A> collectionToModify, Iterator<? extends A> iterator)
      Adds all the elements of the iterator to the collectionToModify
      Type Parameters:
      A - element type
      Parameters:
      collectionToModify - collection to add element to, must not be null
      iterator - source of elements to add, must not be null
      Returns:
      true if any of the elements from iterator were not also in collectionToModify
      Since:
      3.0
    • peekingIterator

      static <A> Iterators.Peeking<A> peekingIterator(Iterator<? extends A> iterator)
      Wrap an iterator to add support for the peek operation. Do not maintain a reference to the iterator passed in as a parameter. Iterators are mutable by nature and this function makes no promises about how or when the input iterator will be mutated.
      Type Parameters:
      A - element type
      Parameters:
      iterator - iterator that may not support peek, must not be null
      Returns:
      an iterator for which peek will return Iterator#next without removing the value from the iterator
      Since:
      3.0
    • singletonIterator

      static <A> Iterator<A> singletonIterator(A a)
      Iterator that returns a single element
      Type Parameters:
      A - element type
      Parameters:
      a - element to return
      Returns:
      iterator returning only a
      Since:
      3.0
    • emptyIterator

      public static <A> Iterator<A> emptyIterator()
      Iterator with no values inside
      Type Parameters:
      A - element type
      Returns:
      empty iterator
      Since:
      3.0