ROOT
6.14/05
Reference Guide
misc
table
src
TTableIter.cxx
Go to the documentation of this file.
1
// @(#)root/table:$Id$
2
// Author: Valery Fine(fine@bnl.gov) 03/12/99
3
4
/*************************************************************************
5
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6
* All rights reserved. *
7
* *
8
* For the licensing terms see $ROOTSYS/LICENSE. *
9
* For the list of contributors see $ROOTSYS/README/CREDITS. *
10
*************************************************************************/
11
12
//////////////////////////////////////////////////////////////////////////
13
// //
14
// TTableIter - class iterator to loop over sorted TTable's //
15
// //
16
//////////////////////////////////////////////////////////////////////////
17
18
#include "
TTableIter.h
"
19
#include "
TTableSorter.h
"
20
21
ClassImp
(
TTableIter
);
22
23
////////////////////////////////////////////////////////////////////////////////
24
///to be documented
25
26
TTableIter::TTableIter
(
const
TTableSorter
*table,
Float_t
&keyvalue)
27
: fTableSorter(table), fIndx(0), fFirstIndx(0)
28
{
29
CountKey
(keyvalue);
30
}
31
32
////////////////////////////////////////////////////////////////////////////////
33
///to be documented
34
35
TTableIter::TTableIter
(
const
TTableSorter
*table,
Long_t
&keyvalue)
36
:
fTableSorter
(table),
fIndx
(0),
fFirstIndx
(0)
37
{
38
CountKey
(keyvalue);
39
}
40
41
////////////////////////////////////////////////////////////////////////////////
42
///to be documented
43
44
TTableIter::TTableIter
(
const
TTableSorter
*table,
Int_t
&keyvalue)
45
:
fTableSorter
(table),
fIndx
(0),
fFirstIndx
(0)
46
{
47
CountKey
(keyvalue);
48
}
49
50
////////////////////////////////////////////////////////////////////////////////
51
///to be documented
52
53
TTableIter::TTableIter
(
const
TTableSorter
*table,
Short_t
&keyvalue)
54
:
fTableSorter
(table),
fIndx
(0),
fFirstIndx
(0)
55
{
56
CountKey
(keyvalue);
57
}
58
59
////////////////////////////////////////////////////////////////////////////////
60
///to be documented
61
62
TTableIter::TTableIter
(
const
TTableSorter
*table,
Double_t
&keyvalue)
63
:
fTableSorter
(table),
fIndx
(0),
fFirstIndx
(0)
64
{
65
CountKey
(keyvalue);
66
}
67
68
////////////////////////////////////////////////////////////////////////////////
69
///to be documented
70
71
Int_t
TTableIter::CountKey
(
Float_t
&keyvalue)
72
{
73
fTotalKeys
=
fTableSorter
->
CountKey
(&keyvalue,0,
kTRUE
,&
fFirstIndx
);
74
return
GetNRows
();
75
}
76
////////////////////////////////////////////////////////////////////////////////
77
///to be documented
78
79
Int_t
TTableIter::CountKey
(
Long_t
&keyvalue)
80
{
81
fTotalKeys
=
fTableSorter
->
CountKey
(&keyvalue,0,
kTRUE
,&
fFirstIndx
);
82
return
GetNRows
();
83
}
84
85
////////////////////////////////////////////////////////////////////////////////
86
///to be documented
87
88
Int_t
TTableIter::CountKey
(
Int_t
&keyvalue)
89
{
90
fTotalKeys
=
fTableSorter
->
CountKey
(&keyvalue,0,
kTRUE
,&
fFirstIndx
);
91
return
GetNRows
();
92
}
93
94
////////////////////////////////////////////////////////////////////////////////
95
///to be documented
96
97
Int_t
TTableIter::CountKey
(
Short_t
&keyvalue)
98
{
99
fTotalKeys
=
fTableSorter
->
CountKey
(&keyvalue,0,
kTRUE
,&
fFirstIndx
);
100
return
GetNRows
();
101
}
102
103
////////////////////////////////////////////////////////////////////////////////
104
///to be documented
105
106
Int_t
TTableIter::CountKey
(
Double_t
&keyvalue)
107
{
108
fTotalKeys
=
fTableSorter
->
CountKey
(&keyvalue,0,
kTRUE
,&
fFirstIndx
);
109
return
GetNRows
();
110
}
111
112
////////////////////////////////////////////////////////////////////////////////
113
///to be documented
114
115
Int_t
TTableIter::Next
()
116
{
117
Int_t
rowIndx = -1;
118
if
(
fIndx
<
fTotalKeys
) {
119
rowIndx =
fTableSorter
->
GetIndex
(
UInt_t
(
fFirstIndx
+
fIndx
));
120
fIndx
++;
121
}
122
return
rowIndx;
123
}
124
125
////////////////////////////////////////////////////////////////////////////////
126
///to be documented
127
128
Int_t
TTableIter::Next
(
Int_t
idx)
129
{
130
Int_t
rowIndx = -1;
131
if
(idx <
fTotalKeys
)
132
rowIndx =
fTableSorter
->
GetIndex
(
UInt_t
(
fFirstIndx
+idx));
133
return
rowIndx;
134
}
135
136
////////////////////////////////////////////////////////////////////////////////
137
///to be documented
138
139
Int_t
TTableIter::Reset
(
Int_t
indx)
140
{
141
Int_t
oldIdx =
fIndx
;
142
fIndx
=
TMath::Min
(indx,
fTotalKeys
);
143
return
oldIdx;
144
}
TTableSorter::GetIndex
Int_t GetIndex(UInt_t sortedIndex) const
returns the original index of the row by its sorted index
Definition:
TTableSorter.cxx:643
TTableSorter.h
TTableIter::Reset
Int_t Reset(Int_t indx=0)
to be documented
Definition:
TTableIter.cxx:139
TTableIter
Definition:
TTableIter.h:24
Float_t
float Float_t
Definition:
RtypesCore.h:53
TTableIter.h
TTableIter::TTableIter
TTableIter()
Definition:
TTableIter.h:33
TTableSorter::CountKey
virtual Int_t CountKey(const void *key, Int_t firstIndx=0, Bool_t bSearch=kTRUE, Int_t *firstRow=0) const
CountKey counts the number of rows with the key value equal "key".
Definition:
TTableSorter.cxx:692
TMath::Min
Short_t Min(Short_t a, Short_t b)
Definition:
TMathBase.h:168
Int_t
int Int_t
Definition:
RtypesCore.h:41
TTableIter::fIndx
Int_t fIndx
Definition:
TTableIter.h:27
TTableIter::fTotalKeys
Int_t fTotalKeys
Definition:
TTableIter.h:28
TTableIter::Next
Int_t Next()
to be documented
Definition:
TTableIter.cxx:115
UInt_t
unsigned int UInt_t
Definition:
RtypesCore.h:42
Short_t
short Short_t
Definition:
RtypesCore.h:35
TTableIter::fTableSorter
const TTableSorter * fTableSorter
Definition:
TTableIter.h:26
Long_t
long Long_t
Definition:
RtypesCore.h:50
TTableIter::CountKey
Int_t CountKey(Float_t &keyvalue)
to be documented
Definition:
TTableIter.cxx:71
ClassImp
#define ClassImp(name)
Definition:
Rtypes.h:359
Double_t
double Double_t
Definition:
RtypesCore.h:55
TTableIter::fFirstIndx
Int_t fFirstIndx
Definition:
TTableIter.h:29
TTableSorter
Definition:
TTableSorter.h:46
kTRUE
const Bool_t kTRUE
Definition:
RtypesCore.h:87
TTableIter::GetNRows
Int_t GetNRows() const
Definition:
TTableIter.h:60