Package htsjdk.samtools

# Class CoordinateSortedPairInfoMap<KEY,REC>

java.lang.Object
htsjdk.samtools.CoordinateSortedPairInfoMap<KEY,REC>

Type Parameters:
  `KEY` - KEY + reference sequence index are used to identify the record being stored or retrieved.
  `REC` - The type of record being retrieved.

All Implemented Interfaces:
  `Iterable<Map.Entry<KEY,REC>>`

public class CoordinateSortedPairInfoMap<KEY,REC> extends Object implements Iterable<Map.Entry<KEY,REC>>
Holds info about a mate pair for use when processing a coordinate sorted file. When one read of a pair is encountered, the caller should add a record to this map. When the other read of a pair is encountered, the record should be removed. This class assumes that reads will be processed in order of reference sequence index. When the map is queried for a record for a given reference sequence index, all the records for that sequence are loaded from temp file into RAM, so there must be sufficient RAM to hold all the records for one reference sequence. If the records are not processed in reference sequence order, loading and unloading of records will cause performance to be terrible.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`CoordinateSortedPairInfoMap.Codec<KEY,REC>`
Client must implement this class, which defines the way in which records are written to and read from file.

## Constructor Summary

Constructors
Constructor
Description
`CoordinateSortedPairInfoMap(int maxOpenFiles, CoordinateSortedPairInfoMap.Codec<KEY,REC> elementCodec)`

## Method Summary

Modifier and Type
Method
Description
`CloseableIterator<Map.Entry<KEY,REC>>`
`iterator()`
Creates an iterator over all elements in map, in arbitrary order.
`void`
`put(int sequenceIndex, KEY key, REC record)`
Store the record with the given sequence index and key.
`REC`
`remove(int sequenceIndex, KEY key)`
`int`
`size()`
`int`
`sizeInRam()`

### Methods inherited from class java.lang.Object

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

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

## Constructor Details

### CoordinateSortedPairInfoMap

public CoordinateSortedPairInfoMap(int maxOpenFiles, CoordinateSortedPairInfoMap.Codec<KEY,REC> elementCodec)

## Method Details

### remove

public REC remove(int sequenceIndex, KEY key)

Parameters:
  `sequenceIndex` -
  `key` -
Returns:
  The record corresponding to the given sequenceIndex and key, or null if it is not present.

### put

public void put(int sequenceIndex, KEY key, REC record)
Store the record with the given sequence index and key. It is assumed that value did not previously exist in the map, and an exception is thrown (possibly at a later time) if that is not the case.

Parameters:
  `sequenceIndex` -
  `key` -
  `record` -

### size

public int size()

### sizeInRam

public int sizeInRam()

Returns:
  number of elements stored in RAM. Always invalid input: '<'= size()

### iterator

public CloseableIterator<Map.Entry<KEY,REC>> iterator()
Creates an iterator over all elements in map, in arbitrary order. Elements may not be added or removed from map when iteration is in progress, nor may a second iteration be started. Iterator must be closed in order to allow normal access to the map.

Specified by:
  `iterator` in interface `Iterable<KEY>`