# Class CounterManager

java.lang.Object
picard.analysis.CounterManager

public class CounterManager extends Object
Class for managing a list of Counters of integer, provides methods to access data from Counters with respect to an offset. Each Counter represents a certain region of a processed sequence starting from offset and can accumulate some value for each locus of this sequence, for instance, read coverage.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`class`
`CounterManager.Counter`
Class represents an integer array with methods to increment and get the values from it with respect to offset of outer `CounterManager`.

## Constructor Summary

Constructors
Constructor
Description
`CounterManager(int arrayLength, int readLength)`
Constructor creates new CounterManager without any Counters, counters are added to CounterManager via newCounter() method

## Method Summary

Modifier and Type
Method
Description
`void`
`checkOutOfBounds(int locusPosition)`
Method checks that new locus position is not out of bounds of Counter arrays and there is enough space in them to hold information on at least one more read of length `readLength`.
`void`
`clear()`
Clears all inner Counter arrays
`CounterManager.Counter`
`newCounter()`
Creates a new Counter object and adds it to the list of managed Counters.

### Methods inherited from class Object

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

## Constructor Details

### CounterManager

public CounterManager(int arrayLength, int readLength)
Constructor creates new CounterManager without any Counters, counters are added to CounterManager via newCounter() method

Parameters:
  `arrayLength` - length of inner Counter arrays
  `readLength` - proposed length of processed reads

## Method Details

### checkOutOfBounds

public void checkOutOfBounds(int locusPosition)
Method checks that new locus position is not out of bounds of Counter arrays and there is enough space in them to hold information on at least one more read of length `readLength`. If there is no free space, but there is accumulated information in Counter arrays after new locus position that we may need, the arrays are rebased, so that 0 index of arrays represents new locus position. In other case, we just clear the arrays.

Parameters:
  `locusPosition` - position in the reference sequence, that will be represented by index 0 of `CounterManager.Counter` arrays.

### clear

public void clear()
Clears all inner Counter arrays

### newCounter

public CounterManager.Counter newCounter()
Creates a new Counter object and adds it to the list of managed Counters.

Returns:
  `CounterManager.Counter`, that will be managed by current `CounterManager`