Package htsjdk.samtools.util

# Class PeekIterator<T>

java.lang.Object
htsjdk.samtools.util.PeekIterator<T>

All Implemented Interfaces:
  `Iterator<T>`

public class PeekIterator<T> extends Object implements Iterator<T>
Wrapper around an iterator that enables non-destructive peeking at the next element that would be returned by next()

## Constructor Summary

Constructors
Constructor
Description
`PeekIterator(Iterator<T> underlyingIterator)`

## Method Summary

Modifier and Type
Method
Description
`Iterator<T>`
`getUnderlyingIterator()`
`boolean`
`hasNext()`
`T`
`next()`
`T`
`peek()`
`void`
`remove()`
Unsupported

### 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`

## Constructor Details

### PeekIterator

public PeekIterator(Iterator<T> underlyingIterator)

## Method Details

### hasNext

public boolean hasNext()

Specified by:
  `hasNext` in interface `Iterator<T>`
Returns:
  true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

### next

public T next()

Specified by:
  `next` in interface `Iterator<T>`
Returns:
  the next element in the iteration. Calling this method repeatedly until the hasNext() method returns false will return each element in the underlying collection exactly once.

### peek

public T peek()

Returns:
  the next element in the iteration, but without removing it, so the next call to next() or peek() will return the same element as returned by the current call to peek().

### remove

public void remove()
Unsupported

Specified by:
  `remove` in interface `Iterator<T>`

### getUnderlyingIterator

public Iterator<T> getUnderlyingIterator()

Returns:
  the iterator wrapped by this object.