Logo ROOT   6.16/01
Reference Guide
cnt001_basictseq.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_cont
3/// \notebook -nodraw
4/// Example showing possible usages of the TSeq class.
5/// \macro_code
6///
7/// \author Danilo Piparo
8
9using namespace ROOT;
10
11void cnt001_basictseq()
12{
13 cout << "Loop on sequence of integers from 0 to 10" << endl;
14 for (auto i : TSeqI(10)) {
15 cout << "Element " << i << endl;
16 }
17 //
18 cout << "Loop on sequence of integers from 3 to 29 in steps of 6" << endl;
19 for (auto i : TSeqI(-5, 29, 6)) {
20 cout << "Element " << i << endl;
21 }
22 //
23 cout << "Loop backwards on sequence of integers from 50 to 30 in steps of 3" << endl;
24 for (auto i : TSeqI(50, 30, -3)) {
25 cout << "Element " << i << endl;
26 }
27 //
28 cout << "stl algorithm, for_each" << endl;
29 TSeqUL ulSeq(2,30,3);
30 std::for_each(std::begin(ulSeq),std::end(ulSeq),[](ULong_t i){cout << "For each: " << i <<endl;});
31
32 cout << "Random access: 3rd element is " << ulSeq[2] << endl;
33 //
34 cout << "Loop using MakeSeq" << endl;
35 for (auto i : MakeSeq(1000000000000UL, 1000000000003UL)) {
36 cout << "Element " << i << endl;
37 }
38}
39
unsigned long ULong_t
Definition: RtypesCore.h:51
A pseudo container class which is a generator of indices.
Definition: TSeq.hxx:66
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
TSeq< T > MakeSeq(T end)
Definition: TSeq.hxx:200
TSeq< int > TSeqI
Definition: TSeq.hxx:194