1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/*
* ============================================================================
*
* Filename: RangeUtils.h
*
* Description: Parse a list of ranges separated by commas.
* Designed for specifying a set of holeNumbers to analyze.
*
* Version: 1.0
* Created: 05/02/2013 12:51:27 PM
* Revision: none
* Compiler: gcc
*
* Author: Yuan Li (yli), yli@pacificbiosciences.com
* Company: Pacific Biosciences
*
* ============================================================================
*/
#include <algorithm>
#include <cstdlib>
#include <pbdata/Types.h>
#include <pbdata/StringUtils.hpp>
class Range
{
public:
UInt start; // Start position of a range, inclusive
UInt end; // End position of a range, inclusive
Range(UInt pStart);
Range(UInt pStart, UInt pEnd);
bool contains(const UInt& query);
bool operator<(const Range& pRange) const;
};
// Input is a comma-delimited string of ranges.
// e.g. 1,2,3,10-20
bool ParseRanges(std::string& rangesStr, std::vector<Range>& ranges);
class Ranges
{
public:
std::vector<Range> ranges;
Ranges(std::string rangesStr = "");
bool setRanges(std::string rangesStr);
int size();
UInt max();
bool contains(const UInt& query);
};
|