@Override
public void seekToTile(final int oneBasedTileNumber) {
while (tileIndexIterator.hasNext()) {
final TileIndex.TileIndexRecord next = tileIndexIterator.next();
if (next.tile > oneBasedTileNumber) {
throw new PicardException(
String.format("Cannot seek backwards: next tile %d > tile sought %d", next.tile, oneBasedTileNumber));
} else if (next.tile == oneBasedTileNumber) {
currentTile = next;
break;
}
}
if (nextRecordIndex > currentTile.indexOfFirstClusterInTile) {
throw new PicardException(
String.format("Seem to be in wrong position %d > %d", nextRecordIndex, currentTile.indexOfFirstClusterInTile));
}
skipRecords(currentTile.indexOfFirstClusterInTile - nextRecordIndex);
nextRecordIndex = currentTile.indexOfFirstClusterInTile;
nextClusterInTile = 0;