StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TTableIter.cxx
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 
13 // //
14 // TTableIter - class iterator to loop over sorted TTable's //
15 // //
17 
18 #include "TTableIter.h"
19 #include "TTableSorter.h"
20 
21 ClassImp(TTableIter);
22 
25 
26 TTableIter::TTableIter(const TTableSorter *table, Float_t &keyvalue)
27  : fTableSorter(table), fIndx(0), fFirstIndx(0)
28 {
29  CountKey(keyvalue);
30 }
31 
34 
35 TTableIter::TTableIter(const TTableSorter *table, Long_t &keyvalue)
36  : fTableSorter(table), fIndx(0), fFirstIndx(0)
37 {
38  CountKey(keyvalue);
39 }
40 
43 
44 TTableIter::TTableIter(const TTableSorter *table, Int_t &keyvalue)
45  : fTableSorter(table), fIndx(0), fFirstIndx(0)
46 {
47  CountKey(keyvalue);
48 }
49 
52 
53 TTableIter::TTableIter(const TTableSorter *table, Short_t &keyvalue)
54  : fTableSorter(table), fIndx(0), fFirstIndx(0)
55 {
56  CountKey(keyvalue);
57 }
58 
61 
62 TTableIter::TTableIter(const TTableSorter *table, Double_t &keyvalue)
63  : fTableSorter(table), fIndx(0), fFirstIndx(0)
64 {
65  CountKey(keyvalue);
66 }
67 
70 
71 Int_t TTableIter::CountKey(Float_t &keyvalue)
72 {
73  fTotalKeys = fTableSorter->CountKey(&keyvalue,0,kTRUE,&fFirstIndx);
74  return GetNRows();
75 }
78 
79 Int_t TTableIter::CountKey(Long_t &keyvalue)
80 {
81  fTotalKeys = fTableSorter->CountKey(&keyvalue,0,kTRUE,&fFirstIndx);
82  return GetNRows();
83 }
84 
87 
88 Int_t TTableIter::CountKey(Int_t &keyvalue)
89 {
90  fTotalKeys = fTableSorter->CountKey(&keyvalue,0,kTRUE,&fFirstIndx);
91  return GetNRows();
92 }
93 
96 
97 Int_t TTableIter::CountKey(Short_t &keyvalue)
98 {
99  fTotalKeys = fTableSorter->CountKey(&keyvalue,0,kTRUE,&fFirstIndx);
100  return GetNRows();
101 }
102 
105 
106 Int_t TTableIter::CountKey(Double_t &keyvalue)
107 {
108  fTotalKeys = fTableSorter->CountKey(&keyvalue,0,kTRUE,&fFirstIndx);
109  return GetNRows();
110 }
111 
114 
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 
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 
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 }
Int_t Reset(Int_t indx=0)
to be documented
Definition: TTableIter.cxx:139
Int_t GetIndex(UInt_t sortedIndex) const
returns the original index of the row by its sorted index
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
Int_t Next()
to be documented
Definition: TTableIter.cxx:115
Int_t CountKey(Float_t &keyvalue)
to be documented
Definition: TTableIter.cxx:71
virtual Int_t CountKey(const void *key, Int_t firstIndx=0, Bool_t bSearch=kTRUE, Int_t *firstRow=0) const