Loading...
Searching...
No Matches
SortedChunkList Class Reference

## Public Member Functions

Chunk | pop ()
bool | insert (const Chunk &chunkToInsert)
void | clear ()
bool | empty ()
bool | mergeOverlapping ()

## Detailed Description

Definition at line 48 of file IndexBase.h.

## Member Function Documentation

## clear()

void SortedChunkList::clear | ( |  | ) |

Definition at line 55 of file IndexBase.cpp.

{
chunkList.clear();
}

## empty()

bool SortedChunkList::empty | ( |  | ) |

Definition at line 60 of file IndexBase.cpp.

{
return(chunkList.empty());
}

## insert()

bool SortedChunkList::insert | ( | const Chunk & | chunkToInsert | ) |

Definition at line 29 of file IndexBase.cpp.

{
std::pair<std::map<uint64_t, Chunk>::iterator, bool> insertRes;
// Insert the passed in chunk.
insertRes =
chunkList.insert(std::pair<uint64_t, Chunk>(chunkToInsert.chunk_beg,
chunkToInsert));
if(!insertRes.second)
{
// Failed to insert the chunk.
std::cerr << "Failed to insert into the SortedChunkList.\n";
std::cerr << "\tpreviously found chunk:\tbeg = " << std::hex
<< insertRes.first->second.chunk_beg
<< "\tend = "
<< insertRes.first->second.chunk_end
<< "\nnew chunk:\tbeg = " << std::hex
<< chunkToInsert.chunk_beg
<< "\tend = "
<< chunkToInsert.chunk_end
<< std::endl;
}
// return the result that comes from insertRes.
return(insertRes.second);
}

## mergeOverlapping()

bool SortedChunkList::mergeOverlapping | ( |  | ) |

Definition at line 67 of file IndexBase.cpp.

{
// Start at the beginning of the list and iterate through.
std::map<uint64_t, Chunk>::iterator currentPos = chunkList.begin();
std::map<uint64_t, Chunk>::iterator nextPos = chunkList.begin();
if(nextPos != chunkList.end())
{
++nextPos;
}
// Loop until the end is reached.
while(nextPos != chunkList.end())
{
// If the next chunk is completely contained within the current
// chunk (its end is less than the current chunk's end),
// delete it since its position is already covered.
if(nextPos->second.chunk_end < currentPos->second.chunk_end)
{
chunkList.erase(nextPos);
nextPos = currentPos;
++nextPos;
continue;
}
// If the next chunk's start position's BGZF block is less than or
// equal to the BGZF block of the current chunk's end position,
// combine the two chunks into the current chunk.
if((nextPos->second.chunk_beg >> 16) <=
(currentPos->second.chunk_end >> 16))
{
currentPos->second.chunk_end = nextPos->second.chunk_end;
// nextPos has now been included in the current pos, so
// remove it.
chunkList.erase(nextPos);
nextPos = currentPos;
++nextPos;
continue;
}
else
{
// Nothing to combine. So try combining at the next
currentPos = nextPos;
++nextPos;
}
}
return(true);
}

## pop()

Chunk SortedChunkList::pop | ( |  | ) |

Definition at line 21 of file IndexBase.cpp.

{
Chunk newChunk = chunkList.begin()->second;
chunkList.erase(chunkList.begin());
return(newChunk);
}
Chunk
Definition IndexBase.h:31

The documentation for this class was generated from the following files:

- general/IndexBase.h
- general/IndexBase.cpp