# cnt001_basictseq¶

Example showing possible usages of the TSeq class.

Author: Danilo Piparo
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Thursday, October 06, 2022 at 09:35 AM.

In :
using namespace ROOT;

In :
cout << "Loop on sequence of integers from 0 to 10" << endl;
for (auto i : TSeqI(10)) {
cout << "Element " << i << endl;
}

Loop on sequence of integers from 0 to 10
Element 0
Element 1
Element 2
Element 3
Element 4
Element 5
Element 6
Element 7
Element 8
Element 9

In :
cout << "Loop on sequence of integers from -5 to 29 in steps of 6" << endl;
for (auto i : TSeqI(-5, 29, 6)) {
cout << "Element " << i << endl;
}

Loop on sequence of integers from -5 to 29 in steps of 6
Element -5
Element 1
Element 7
Element 13
Element 19
Element 25

In :
cout << "Loop backwards on sequence of integers from 50 to 30 in steps of 3" << endl;
for (auto i : TSeqI(50, 30, -3)) {
cout << "Element " << i << endl;
}

Loop backwards on sequence of integers from 50 to 30 in steps of 3
Element 50
Element 47
Element 44
Element 41
Element 38
Element 35
Element 32

In :
cout << "stl algorithm, for_each" << endl;
TSeqUL ulSeq(2,30,3);
std::for_each(std::begin(ulSeq),std::end(ulSeq),[](ULong_t i){cout << "For each: " << i <<endl;});

cout << "Random access: 3rd element is " << ulSeq << endl;

stl algorithm, for_each
For each: 2
For each: 5
For each: 8
For each: 11
For each: 14
For each: 17
For each: 20
For each: 23
For each: 26
For each: 29
Random access: 3rd element is 8

In :
cout << "Loop using MakeSeq" << endl;
for (auto i : MakeSeq(1000000000000UL, 1000000000003UL)) {
cout << "Element " << i << endl;
}

Loop using MakeSeq
Element 1000000000000
Element 1000000000001
Element 1000000000002