118 ,
Int_t numberRows):fsimpleArray(0),fParentTable(&
table)
139 ,
Int_t numberRows):fsimpleArray(0),fParentTable(
table)
167 :fsimpleArray(0),fParentTable(&
table)
171 TString colName =
"user's defined";
195 :fsimpleArray(0),fParentTable(
table)
199 TString colName =
"user's defined";
255 while((br = strchr(br+1,
'['))) {
269 const char *openBracket = colName.
Data()-1;
270 const char *closeBracket = colName.
Data()-1;
272 openBracket = strchr(openBracket+1,
'[');
273 closeBracket = strchr(closeBracket+1,
']');
274 if (closeBracket > openBracket)
277 Error(
"TTable ctor",
"Wrong parethethis <%s>",colName.
Data());
283 if (colName !=
"user's defined") {
302 :fsimpleArray((const
Char_t*)simpleArray)
325 if (sample > *p) isPreSorted =
kFALSE;
331 if (!isPreSorted)
QSort();
346 :fsimpleArray((const
Char_t*)simpleArray)
369 if (sample > *p) isPreSorted =
kFALSE;
375 if (!isPreSorted)
QSort();
390 :fsimpleArray((const
Char_t*)simpleArray)
413 if (sample > *p) isPreSorted =
kFALSE;
418 if (!isPreSorted)
QSort();
437 if (firstRow > arraySize)
return;
471#define BINARYSEARCH(valuetype) Int_t TTableSorter::BinarySearch(valuetype value) const {\
472 switch (fColType) { \
473 case TTable::kFloat: \
474 return SelectSearch(Float_t(value)); \
475 case TTable::kInt : \
476 return SelectSearch(Int_t(value)); \
477 case TTable::kLong : \
478 return SelectSearch(Long_t(value)); \
479 case TTable::kShort : \
480 return SelectSearch(Short_t(value)); \
481 case TTable::kDouble : \
482 return SelectSearch(Double_t(value)); \
483 case TTable::kUInt: \
484 return SelectSearch(UInt_t(value)); \
485 case TTable::kULong : \
486 return SelectSearch(ULong_t(value)); \
487 case TTable::kUShort: \
488 return SelectSearch(UShort_t(value)); \
489 case TTable::kBool: \
490 return SelectSearch(Bool_t(value)); \
491 case TTable::kUChar: \
492 return SelectSearch(UChar_t(value)); \
493 case TTable::kChar: \
494 return SelectSearch(Char_t(value)); \
500Int_t TTableSorter::BSearch(valuetype value) const{ \
501 union { Bool_t Bool; \
514 switch (fColType) { \
515 case TTable::kFloat: \
516 value_.Float = Float_t(value); break; \
517 case TTable::kInt : \
518 value_.Int = Int_t(value); break; \
519 case TTable::kLong : \
520 value_.Long = Long_t(value); break; \
521 case TTable::kShort : \
522 value_.Short = Short_t(value); break; \
523 case TTable::kDouble : \
524 value_.Double= Double_t(value);break; \
525 case TTable::kUInt: \
526 value_.UInt = UInt_t(value); break; \
527 case TTable::kULong : \
528 value_.ULong = ULong_t(value); break; \
529 case TTable::kUShort: \
530 value_.UShort= UShort_t(value);break; \
531 case TTable::kUChar: \
532 value_.UChar = UChar_t(value); break; \
533 case TTable::kChar: \
534 value_.Char = Char_t(value); break; \
535 case TTable::kBool: \
536 value_.Bool = Bool_t(value); break; \
541 return BSearch(&value_); \
543Int_t TTableSorter::SelectSearch(valuetype value) const { \
544 valuetype **array = (valuetype **)fSortIndex; \
545 Int_t nabove, nbelow, middle; \
546 nabove = fNumberOfRows+1; \
548 while(nabove-nbelow > 1) { \
549 middle = (nabove+nbelow)/2; \
550 if (value == *array[middle-1]) { nbelow = middle; break; } \
551 if (value < *array[middle-1]) nabove = middle; \
552 else nbelow = middle; \
555 ((TTableSorter *)this)->fLastFound = nbelow; \
556 if (nbelow < 0) return nbelow; \
557 return GetIndex(nbelow); \
560#define COMPAREFLOATVALUES(valuetype) \
561int TTableSorter::Search##valuetype (const void *elem1, const void **elem2) { \
562 valuetype *value1 = (valuetype *)(elem1); \
563 valuetype *value2 = (valuetype *)(*elem2); \
564 valuetype diff = *value1-*value2; \
566 if (diff > 0) res = 1; \
567 else if (diff < 0) res = -1; \
570int TTableSorter::Compare##valuetype (const void **elem1, const void **elem2) {\
571 valuetype *value1 = (valuetype *)(*elem1); \
572 valuetype *value2 = (valuetype *)(*elem2); \
573 valuetype diff = *value1-*value2; \
575 if (diff > 0 ) res = 1; \
576 else if (diff < 0) res = -1; \
577 if (res) return res; \
578 return int(value1-value2); \
580BINARYSEARCH(valuetype)
584#define COMPAREVALUES(valuetype) \
585int TTableSorter::Search##valuetype (const void *elem1, const void **elem2) { \
586 valuetype *value1 = (valuetype *)(elem1); \
587 valuetype *value2 = (valuetype *)(*elem2); \
588 return int(*value1-*value2); \
590int TTableSorter::Compare##valuetype (const void **elem1, const void **elem2) { \
591 valuetype *value1 = (valuetype *)(*elem1); \
592 valuetype *value2 = (valuetype *)(*elem2); \
593 valuetype diff = *value1-*value2; \
594 if (diff ) return diff; \
595 return int(value1-value2); \
597BINARYSEARCH(valuetype)
611#define COMPAREORDER(valuetype) Compare##valuetype
612#define SEARCHORDER(valuetype) Search##valuetype
621 void **p = (
void **)::bsearch((
void *) value,
664int TTableSorter::CompareUChar (
const void *elem1,
const void *elem2)
674int TTableSorter::CompareChar (
const void *elem1,
const void *elem2)
695 if (firstRow) *firstRow = -1;
697 Int_t indx = firstIndx;
712 if (firstRow && count) *firstRow = indx-count;
751 const void *sample = row;
904 if (!classPtr)
return;
907 if (!(classPtr->
GetNdata()))
return;
922 if (!strcmp(
"float", types))
924 else if (!strcmp(
"int", types))
926 else if (!strcmp(
"long", types))
928 else if (!strcmp(
"short", types))
930 else if (!strcmp(
"double", types))
932 else if (!strcmp(
"unsigned int", types))
934 else if (!strcmp(
"unsigned long", types))
936 else if (!strcmp(
"unsigned short", types))
938 else if (!strcmp(
"unsigned char", types))
940 else if (!strcmp(
"char", types))
942 else if (!strcmp(
"bool", types))
947 Int_t globalIndex = 0;
951 Error(
"LearnTable",
"Wrong dimension");
971#undef COMPAREFLOATVALUES
char * StrDup(const char *str)
Duplicate the string str.
#define SEARCHORDER(valuetype)
#define COMPAREFLOATVALUES(valuetype)
#define COMPAREVALUES(valuetype)
#define COMPAREORDER(valuetype)
Int_t(* CALLQSORT)(const void *, const void *)
Int_t(* COMPAREMETHOD)(const void **, const void **)
Int_t(* SEARCHMETHOD)(const void *, const void **)
The ROOT global object gROOT contains a list of all defined classes.
void BuildRealData(void *pointer=0, Bool_t isTransient=kFALSE)
Build a full list of persistent data members.
Int_t GetNdata()
Return the number of data members of this class Note that in case the list of data members is not yet...
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
TList * GetListOfRealData() const
All ROOT classes may have RTTI (run time type identification) support added.
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
Long_t GetOffset() const
Get offset from "this".
Int_t GetArrayDim() const
Return number of array dimensions.
TDataType * GetDataType() const
Basic data type descriptor (datatype information is obtained from CINT).
TString GetTypeName()
Get basic type of typedef, e,g.
Int_t Size() const
Get size of basic typedef'ed type.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * Data() const
virtual Int_t GetLastFound() const
void SetSearchMethod()
Select search function at once.
virtual Int_t FindFirstKey(const void *key) const
Looks for the first index of the "key" within SORTED table AFTER sorting.
void SetSimpleArray(Int_t arraySize, Int_t firstRow, Int_t numberRows)
Set some common parameteres for the "simple" arrays.
TTable::EColumnType fColType
virtual Int_t CountKeys() const
Counts the number of different key values.
virtual const char * GetTableTitle() const
to be documented
void QSort()
Call the standard C run-time library "qsort" function.
virtual const char * GetTableType() const
to be documented
virtual TTable * GetTable() const
to be documented
SEARCHMETHOD fSearchMethod
const Char_t * fsimpleArray
const char * fFirstParentRow
virtual ~TTableSorter()
to be documented
const char * At(Int_t i) const
const TTable * fParentTable
void BuildSorter(TString &colName, Int_t firstRow, Int_t numberRows)
BuildSorter backs TTableSorter ctor.
Int_t BSearch(const void *value) const
to be documented
COMPAREMETHOD fCompareMethod
virtual Int_t GetNRows() const
Int_t GetIndex(UInt_t sortedIndex) const
returns the original index of the row by its sorted index
void LearnTable()
LearnTable() allows the TTableSorter to learn the structure of the tables used to fill the ntuple.
virtual const char * GetTableName() const
to be documented
Bool_t FillIndexArray()
File the array of the pointers and check whether the original table has been sorted to avoid an extra...
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".
virtual Long_t GetRowSize() const
Returns the size (in bytes) of one table row.
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
virtual const Char_t * GetType() const
Returns the type of the wrapped C-structure kept as the TNamed title.
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
virtual TClass * GetRowClass() const
to be documented
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)