# Class CramContainerHeaderIterator

java.lang.Object
htsjdk.samtools.cram.build.CramContainerIterator
htsjdk.samtools.cram.build.CramContainerHeaderIterator

All Implemented Interfaces:
  `Closeable, AutoCloseable, Iterator<Container>`

public final class CramContainerHeaderIterator extends CramContainerIterator
Iterate over CRAM containers from an input stream, and unlike `CramContainerIterator` only the header of each container is read, rather than the whole stream. As a result, the container block data is *not* populated, including the compression header block and slices. This class is useful when you are not interested in the contents of containers, for example when indexing container start positions.

## Constructor Summary

Constructors
Constructor
Description
`CramContainerHeaderIterator(InputStream inputStream)`

## Method Summary

Modifier and Type
Method
Description
`protected Container`
`containerFromStream(CountingInputStream countingStream)`
Consume the entirety of the next container from the stream, but retain only the header.

### Methods inherited from class CramContainerIterator

`close, getCramHeader, getSamFileHeader, hasNext, next, remove`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface Iterator

`forEachRemaining`

## Constructor Details

### CramContainerHeaderIterator

public CramContainerHeaderIterator(InputStream inputStream)

## Method Details

### containerFromStream

protected Container containerFromStream(CountingInputStream countingStream)
Consume the entirety of the next container from the stream, but retain only the header. This is intended as a performance optimization, because it does not decode block data.

Overrides:
  `containerFromStream` in class `CramContainerIterator`
Parameters:
  `countingStream` - the `CountingInputStream` to read from
Returns:
  The next Container's header from the stream, returned as a Container.
See Also:
  - `CramContainerIterator.containerFromStream(CountingInputStream)`