11 #ifndef ROOT_TTableSorter
12 #define ROOT_TTableSorter
15 #include "TTableDescriptor.h"
43 typedef Int_t (*COMPAREMETHOD)(
const void **,
const void **);
44 typedef Int_t (*SEARCHMETHOD) (
const void *,
const void **);
70 const Char_t *fsimpleArray;
71 const TTable *fParentTable;
73 COMPAREMETHOD fCompareMethod;
74 TTable::EColumnType fColType;
75 Long_t fParentRowSize;
76 const char *fFirstParentRow;
79 static int CompareInt_t (
const void **,
const void **);
80 static int CompareLong_t (
const void **,
const void **);
81 static int CompareULong_t (
const void **,
const void **);
82 static int CompareUInt_t (
const void **,
const void **);
83 static int CompareShort_t (
const void **,
const void **);
84 static int CompareDouble_t (
const void **,
const void **);
85 static int CompareUShort_t (
const void **,
const void **);
86 static int CompareUChar_t (
const void **,
const void **);
87 static int CompareChar_t (
const void **,
const void **);
88 static int CompareBool_t (
const void **,
const void **);
90 Int_t
BSearch(
const void *value)
const;
92 Int_t
BSearch(Float_t value )
const;
93 Int_t
BSearch(Int_t value )
const;
94 Int_t
BSearch(ULong_t value )
const;
95 Int_t
BSearch(Long_t value )
const;
96 Int_t
BSearch(UInt_t value )
const;
97 Int_t
BSearch(Short_t value )
const;
98 Int_t
BSearch(Double_t value )
const;
99 Int_t
BSearch(UShort_t value )
const;
100 Int_t
BSearch(UChar_t value )
const;
101 Int_t
BSearch(Char_t value )
const;
102 Int_t
BSearch(Bool_t value )
const;
112 static int SearchFloat_t (
const void *,
const void **);
113 static int SearchInt_t (
const void *,
const void **);
114 static int SearchULong_t (
const void *,
const void **);
115 static int SearchLong_t (
const void *,
const void **);
116 static int SearchUInt_t (
const void *,
const void **);
117 static int SearchShort_t (
const void *,
const void **);
118 static int SearchDouble_t (
const void *,
const void **);
119 static int SearchUShort_t (
const void *,
const void **);
120 static int SearchUChar_t (
const void *,
const void **);
121 static int SearchChar_t (
const void *,
const void **);
122 static int SearchBool_t (
const void *,
const void **);
124 Int_t SelectSearch(Float_t value )
const;
125 Int_t SelectSearch(Int_t value )
const;
126 Int_t SelectSearch(ULong_t value )
const;
127 Int_t SelectSearch(Long_t value )
const;
128 Int_t SelectSearch(UInt_t value )
const;
129 Int_t SelectSearch(Short_t value )
const;
130 Int_t SelectSearch(Double_t value )
const;
131 Int_t SelectSearch(UShort_t value )
const;
132 Int_t SelectSearch(UChar_t value )
const;
133 Int_t SelectSearch(Char_t value )
const;
134 Int_t SelectSearch(Bool_t value )
const;
137 void SetSimpleArray(Int_t arraySize, Int_t firstRow,Int_t numberRows);
138 void BuildSorter(TString &colName, Int_t firstRow, Int_t numberRows);
139 const char *At(Int_t i)
const;
143 TTableSorter(
const TTable &table, TString &colName, Int_t firstRow=0,Int_t numbeRows=0);
144 TTableSorter(
const TTable *table, TString &colName, Int_t firstRow=0,Int_t numbeRows=0);
146 TTableSorter(
const TTable &table, SEARCHMETHOD search, COMPAREMETHOD compare, Int_t firstRow=0,Int_t numbeRows=0);
147 TTableSorter(
const TTable *table, SEARCHMETHOD search, COMPAREMETHOD compare, Int_t firstRow=0,Int_t numbeRows=0);
149 TTableSorter(
const Float_t *simpleArray, Int_t arraySize, Int_t firstRow=0,Int_t numberRows=0);
150 TTableSorter(
const Double_t *simpleArray, Int_t arraySize, Int_t firstRow=0,Int_t numberRows=0);
151 TTableSorter(
const Long_t *simpleArray, Int_t arraySize, Int_t firstRow=0,Int_t numberRows=0);
154 virtual Int_t
CountKey(
const void *key, Int_t firstIndx=0,Bool_t bSearch=kTRUE,Int_t *firstRow=0)
const;
158 Int_t BinarySearch(Float_t value )
const;
159 Int_t BinarySearch(Int_t value )
const;
160 Int_t BinarySearch(ULong_t value )
const;
161 Int_t BinarySearch(Long_t value )
const;
162 Int_t BinarySearch(UInt_t value )
const;
163 Int_t BinarySearch(Short_t value )
const;
164 Int_t BinarySearch(Double_t value )
const;
165 Int_t BinarySearch(UShort_t value )
const;
166 Int_t BinarySearch(UChar_t value )
const;
167 Int_t BinarySearch(Char_t value )
const;
168 Int_t BinarySearch(Bool_t value )
const;
170 virtual const char *GetColumnName()
const {
return fColName.Data();}
171 Int_t
GetIndex(UInt_t sortedIndex)
const;
172 virtual const void *GetKeyAddress(Int_t indx) {
return (fSortIndex && indx >= 0) ?fSortIndex[indx]:(
void *)(-1);}
173 virtual Int_t GetLastFound()
const {
return fLastFound; }
178 virtual Int_t GetNRows()
const {
return fNumberOfRows;}
179 virtual Int_t GetFirstRow()
const {
return fFirstRow;}
181 Int_t operator[](Int_t value)
const;
182 Int_t operator[](Long_t value)
const;
183 Int_t operator[](Double_t value)
const;
184 Int_t operator[](
void *value)
const;
188 Int_t operator()(Float_t value);
189 Int_t operator()(Int_t value);
190 Int_t operator()(Long_t value);
191 Int_t operator()(Double_t value);
198 inline const char *TTableSorter::At(Int_t i)
const {
return fFirstParentRow + i*fParentRowSize;}
199 inline Long_t TTableSorter::GetRowSize() {
return fParentRowSize; }
201 inline Int_t TTableSorter::operator[](Int_t value)
const {
return BSearch(value); }
202 inline Int_t TTableSorter::operator[](Long_t value)
const {
return BSearch(value); }
203 inline Int_t TTableSorter::operator[](Double_t value)
const {
return BSearch(value); }
204 inline Int_t TTableSorter::operator[](
void *value)
const {
return BSearch(value); }
206 inline Int_t TTableSorter::operator()(Float_t value) {
return BinarySearch(value); }
207 inline Int_t TTableSorter::operator()(Int_t value) {
return BinarySearch(value); }
208 inline Int_t TTableSorter::operator()(Long_t value) {
return BinarySearch(value); }
209 inline Int_t TTableSorter::operator()(Double_t value) {
return BinarySearch(value); }
static int CompareFloat_t(const void **, const void **)
pointer to the internal array of TTable object;
virtual Int_t FindFirstKey(const void *key) const
virtual const char * GetTableTitle() const
to be documented
Int_t GetIndex(UInt_t sortedIndex) const
returns the original index of the row by its sorted index
virtual const char * GetTableType() const
to be documented
void SetSearchMethod()
Select search function at once.
void BuildSorter(TString &colName, Int_t firstRow, Int_t numberRows)
Int_t BSearch(const void *value) const
to be documented
virtual TTable * GetTable() const
to be documented
SEARCHMETHOD fSearchMethod
virtual const char * GetTableName() const
to be documented
virtual ~TTableSorter()
to be documented
virtual Int_t CountKey(const void *key, Int_t firstIndx=0, Bool_t bSearch=kTRUE, Int_t *firstRow=0) const
void SetSimpleArray(Int_t arraySize, Int_t firstRow, Int_t numberRows)
Set some common parameteres for the "simple" arrays.
virtual Int_t CountKeys() const