TTableSorter - Is an "observer" class to sort the TTable objects
The class provides an interface to the standard "C/C++"
qsort and bsearch subroutines (for further information see your local C/C++ docs)
===== =======
- This class DOESN'T change / touch the "host" table itself
For any TTable object one can create as many different "sorter"
as he/she finds useful for his/her code
- Any instance of this class is meaningful as long as the "host" object
"TTable" does exist and is not changed
- Any attempt to access this TTableSorter after the "host" object deleted
causes the program abnormal termination
- Any attempt to access this TTableSorter after the "host" object been changed
causes an unpredictable result
- Any instance (object) of this class is NOT deleted "by automatic" just
the "host object "TTable" deleted. It is the responsibility of the user's code
keeping TTableSorter and the the "host" TTable objects consistent.
"To do" list
1. A separate method to provide lexicographical sort if the "sorted" column is a kind of array
Usage:
1. Create an instance of the sorter for the selected column of your table
new TTableSorter(TTable &table, TString &colName,Int_t firstRow,Int_t numberRows)
All sort actions are performed within TTableSorter ctor.
This means one needs no extra effort to SORT table. "Sorter" contains
the "sorted index array" as soon as you create the sorter
TTableSorter sorter(MyTable,"id",20, 34);
- Creates a sorter for MyTable column "id" ordering
its 34 rows from 20 row with standard "C" qsort subroutine
2. You may use this instance to search any "id" value with operator []
to get the table row index as follows:
Int_t id = 5;
Int_t index = sorter[id]; // Look for the row index with id = 5
// using the standard "C" "bsearch" binary search
// subroutine
Int_t index = sorter(id); // Look for the row index with id "nearest" to 5
// using the internal "BinarySearch" method
3. Some useful methods of this class:
3.1. CountKeys()
3.2 CountKey(const void *key, Int_t firstIndx=0,Bool_t bSearch=kTRUE,Int_t *firstRow=0)
3.3. FindFirstKey(const void *key)
3.4. GetIndex(UInt_t sortedIndex)

TTableSorter ctor sorts the input table along its column defined with colName
- colName - may be followed by the square brackets with integer number inside,
if that columm is an array (for example "phys[3]").
NO expression inside of [], only a single integer number allowed !
- firstRow - the first table row to sort from (=0 by default)
- numberRows - the number of the table rows to sort (=0 by default)
= 0 means sort all rows from the "firstRow" by the end of table

TTableSorter ctor sorts the input table along its column defined with colName
- colName - may be followed by the square brackets with integer number inside,
if that columm is an array (for example "phys[3]").
NO expression inside of [], only a single integer number allowed !
- firstRow - the first table row to sort from (=0 by default)
- numberRows - the number of the table rows to sort (=0 by default)
= 0 means sort all rows from the "firstRow" by the end of table

TTableSorter ctor sorts the input table according the function "search"
- search - the function to compare the "key" and the table rows during sorting
typedef Int_t (*SEARCHMETHOD) (const void *, const void **);
- compare - the function to compare two table rows during searching
typedef Int_t (*COMPAREMETHOD)(const void **, const void **);
- firstRow - the first table row to sort from (=0 by default)
- numberRows - the number of the table rows to sort (=0 by default)
= 0 means sort all rows from the "firstRow" by the end of table
Note: This is a base class. If one fears it is not safe
----- to allow "void *" one may potect the end-user code
providing a derived class with the appropriated type
of the parameters.

TTableSorter ctor sorts the input table according the function "search"
- search - the function to compare the "key" and the table rows during sorting
typedef Int_t (*SEARCHMETHOD) (const void *, const void **);
- compare - the function to compare two table rows during searching
typedef Int_t (*COMPAREMETHOD)(const void **, const void **);
- firstRow - the first table row to sort from (=0 by default)
- numberRows - the number of the table rows to sort (=0 by default)
= 0 means sort all rows from the "firstRow" by the end of table
Note: This is a base class. If one fears it is not safe
----- to allow "void *" one may potect the end-user code
providing a derived class with the appropriated type
of the parameters.

BuildSorter backs TTableSorter ctor
- colName - may be followed by the square brackets with integer number inside,
if that columm is an array (for example "phys[3]").
NO expression inside of [], only a single integer number allowed !
- firstRow - the first table row to sort from (=0 by default)
- numberRows - the number of the table rows to sort (=0 by default)
= 0 means sort all rows from the "firstRow" by the end of table

TTableSorter ctor sort the input "simpleArray"
- arraySize - the size of the full array
- firstRow - the first table row to sort from (=0 by default)
- numberRows - the number of the table rows to sort (=0 by default)
= 0 means sort all rows from the "firstRow" by the end of table

TTableSorter ctor sort the input "simpleArray"
- arraySize - the size of the full array
- firstRow - the first table row to sort from (=0 by default)
- numberRows - the number of the table rows to sort (=0 by default)
= 0 means sort all rows from the "firstRow" by the end of table

TTableSorter ctor sort the input "simpleArray"
- arraySize - the sie of the full array
- firstRow - the first table row to sort from (=0 by default)
- numberRows - the number of the table rows to sort (=0 by default)
= 0 means sort all rows from the "firstRow" by the end of table

CountKey counts the number of rows with the key value equal "key"
key - it is a POINTER to the key value
fistIndx - the first index within sorted array to star search
= 0 by default
bSearch = kTRUE - binary search (by default) is used otherwise linear one

Looks for the first index of the "key"
within SORTED table AFTER sorting
Returns: = -1 if the "key" was not found
Note: This method has no sense for
==== the float and double key
To get the index within the original
unsorted table the GetIndex() method
may be used like this:
GetIndex(FindFirstKey(key))

LearnTable() allows the TTableSorter to learn the structure of the
tables used to fill the ntuple.
table - the name of the table
buildTree - if kTRUE, then add TBranches to the TTree for each table
column (default=kFALSE)

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.