Class
Splitter
Splits an interval into subintervals.
This class divides an interval into the disjoint union of subintervals and enumerates its boundaries. It can be used to parallelize large for-loops that iterate over a contiguous range of elements. The interval and the number of subintervals can be set in the constructor Splitter. length and resize can be used to retrieve or change the number of subintervals later. In contrast to other containers the Splitter allows to access one more element than its length would imply to allow to retrieve the right boundary of each subinterval (see example code below).

Splitter

Equidistant Splitter

Splitter<TValue, TSpec>
Include Headers
seqan/parallel.h
Parameters

TValue | Type of the interval boundaries.
TSpec | Tag to select the way the values are sampled. Default: Equidistant Splitter

Specializations

Equidistant Splitter | Splits an interval into equal-sized subintervals.

Metafunctions

Size | Type of an object that is suitable to hold size information.
Value | Type of the items in the container or behind an iterator.

Member Functions

Splitter | Constructor

Functions

length | The number of items/characters.
resize | Resizes a container. If the new length exceeds the old length the new elements are filled with copies of value.

Examples
Simple example for equidistant (default) splitting.
File "splitter_example.cpp"

1 | #include <iostream>
2 | #include <seqan/parallel.h>
3 |
4 | using namespace seqan;
5 |
6 | int main ()
7 | {
8 | // instantiate a Splitter to divide the interval [10,20) in 3 subintervals
9 | Splitter<unsigned> splitter(10, 20, 3);
10 |
11 | // output all subintervals
12 | for (unsigned i = 0; i < length(splitter); ++i)
13 | std::cout << '[' << splitter[i] << ',' << splitter[i + 1] << ')' << std::endl;
14 |
15 | return 0;
16 | }

[10,14)
[14,17)
[17,20)
SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2014/10/13 16:12:56