libStatGen Software  1
PosList Class Reference

Store refID/position, but does not store values < 0. More...

#include <PosList.h>

Inheritance diagram for PosList:
Collaboration diagram for PosList:

List of all members.

Public Member Functions

 PosList ()
 Constructor.
 PosList (int numRefs, int numPositions)
 Reserves space for numRefs reference ids and numPositions for each id.
virtual ~PosList ()
 Destructor.
void addPosition (int refID, int refPosition)
 Add the specified reference id/position (negative values will not be added).
bool hasPosition (int refID, int refPosition)
 Return whether or not this list contains the specified reference ID and position (negative values will automatically return false).

Protected Member Functions

 PosList (const PosList &p)
void initVars ()

Protected Attributes

std::vector< std::vector< bool > > myPosList
int myNumRefs
int myNumPos

Detailed Description

Store refID/position, but does not store values < 0.

Definition at line 24 of file PosList.h.


Member Function Documentation

void PosList::addPosition ( int  refID,
int  refPosition 
)

Add the specified reference id/position (negative values will not be added).

Definition at line 42 of file PosList.cpp.

{
    // Check for negative numbers, if so, just return.
    if((refID < 0) || (refPosition < 0))
    {
        return;
    }

    // If the position list is smaller or equal to refID, it cannot handle an index,
    // so increase the size.
    if(myPosList.size() <= (unsigned int)refID)
    {
        // The position list does not currently have space for this reference id,
        // so add it.
        myPosList.resize(refID+1, std::vector<bool>(myNumPos, false));
        myNumRefs = refID + 1;
    }

    // The matrix is now sized for this reference id.
    // Check to see if this id holds this position.
    if((myPosList[refID]).size() <= (unsigned int)refPosition)
    {
        // The index for this position has not yet been created,
        // so increase the size for it.
        if(myNumPos <= refPosition)
        {
            // Our number of positions is smaller than
            // the current reference id, so reset
            // myNumPos for future use to be this position +1.
            myNumPos = refPosition + 1;
        }
        // Increase the size for this reference id to hold at least myNumPos.
        (myPosList[refID]).resize(myNumPos, false);
    }

    // It now holds this position, so set it to true.
    myPosList[refID][refPosition] = true;
}
bool PosList::hasPosition ( int  refID,
int  refPosition 
)

Return whether or not this list contains the specified reference ID and position (negative values will automatically return false).

Definition at line 81 of file PosList.cpp.

Referenced by Pileup< PILEUP_TYPE, FUNC_CLASS >::processAlignmentRegion().

{
    // Check for negative numbers, if so, just return false, not found.
    if((refID < 0) || (refPosition < 0))
    {
        return(false);
    }
    bool found = false;
    try
    {
        if((myPosList.at(refID)).at(refPosition))
        {
            found = true;
        }
    }
    catch (std::out_of_range& oor)
    {
            // Nothing to do here, if it was out of range, then
            // the position was not found (already set to false).
    }
    return(found);
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends