Logo ROOT   6.18/05
Reference Guide
cnt001_basictseq.C File Reference

Detailed Description

View in nbviewer Open in SWAN Example showing possible usages of the TSeq class.

using namespace ROOT;
void cnt001_basictseq()
{
cout << "Loop on sequence of integers from 0 to 10" << endl;
for (auto i : TSeqI(10)) {
cout << "Element " << i << endl;
}
//
cout << "Loop on sequence of integers from 3 to 29 in steps of 6" << endl;
for (auto i : TSeqI(-5, 29, 6)) {
cout << "Element " << i << endl;
}
//
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;
}
//
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[2] << endl;
//
cout << "Loop using MakeSeq" << endl;
for (auto i : MakeSeq(1000000000000UL, 1000000000003UL)) {
cout << "Element " << i << endl;
}
}
unsigned long ULong_t
Definition: RtypesCore.h:51
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
TSeq< unsigned long > TSeqUL
Definition: TSeq.hxx:197
TSeq< T > MakeSeq(T end)
Definition: TSeq.hxx:200
TSeq< int > TSeqI
Definition: TSeq.hxx:194
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
Loop on sequence of integers from 3 to 29 in steps of 6
Element -5
Element 1
Element 7
Element 13
Element 19
Element 25
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
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
Loop using MakeSeq
Element 1000000000000
Element 1000000000001
Element 1000000000002
Author
Danilo Piparo

Definition in file cnt001_basictseq.C.