StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
TTableSorter Class Reference
Inheritance diagram for TTableSorter:

Public Member Functions

 TTableSorter (const TTable &table, TString &colName, Int_t firstRow=0, Int_t numbeRows=0)
 
 TTableSorter (const TTable *table, TString &colName, Int_t firstRow=0, Int_t numbeRows=0)
 
 TTableSorter (const TTable &table, SEARCHMETHOD search, COMPAREMETHOD compare, Int_t firstRow=0, Int_t numbeRows=0)
 
 TTableSorter (const TTable *table, SEARCHMETHOD search, COMPAREMETHOD compare, Int_t firstRow=0, Int_t numbeRows=0)
 
 TTableSorter (const Float_t *simpleArray, Int_t arraySize, Int_t firstRow=0, Int_t numberRows=0)
 
 TTableSorter (const Double_t *simpleArray, Int_t arraySize, Int_t firstRow=0, Int_t numberRows=0)
 
 TTableSorter (const Long_t *simpleArray, Int_t arraySize, Int_t firstRow=0, Int_t numberRows=0)
 
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
 
virtual Int_t CountKeys () const
 
virtual Int_t FindFirstKey (const void *key) const
 
Int_t BinarySearch (Float_t value) const
 
Int_t BinarySearch (Int_t value) const
 
Int_t BinarySearch (ULong_t value) const
 
Int_t BinarySearch (Long_t value) const
 
Int_t BinarySearch (UInt_t value) const
 
Int_t BinarySearch (Short_t value) const
 
Int_t BinarySearch (Double_t value) const
 
Int_t BinarySearch (UShort_t value) const
 
Int_t BinarySearch (UChar_t value) const
 
Int_t BinarySearch (Char_t value) const
 
Int_t BinarySearch (Bool_t value) const
 
virtual const char * GetColumnName () const
 
Int_t GetIndex (UInt_t sortedIndex) const
 returns the original index of the row by its sorted index
 
virtual const void * GetKeyAddress (Int_t indx)
 
virtual Int_t GetLastFound () const
 
virtual const char * GetTableName () const
 to be documented
 
virtual const char * GetTableTitle () const
 to be documented
 
virtual const char * GetTableType () const
 to be documented
 
virtual TTableGetTable () const
 to be documented
 
virtual Int_t GetNRows () const
 
virtual Int_t GetFirstRow () const
 
Int_t operator[] (Int_t value) const
 
Int_t operator[] (Long_t value) const
 
Int_t operator[] (Double_t value) const
 
Int_t operator[] (void *value) const
 
Int_t operator() (Float_t value)
 
Int_t operator() (Int_t value)
 
Int_t operator() (Long_t value)
 
Int_t operator() (Double_t value)
 

Protected Member Functions

Int_t BSearch (const void *value) const
 to be documented
 
Int_t BSearch (Float_t value) const
 
Int_t BSearch (Int_t value) const
 
Int_t BSearch (ULong_t value) const
 
Int_t BSearch (Long_t value) const
 
Int_t BSearch (UInt_t value) const
 
Int_t BSearch (Short_t value) const
 
Int_t BSearch (Double_t value) const
 
Int_t BSearch (UShort_t value) const
 
Int_t BSearch (UChar_t value) const
 
Int_t BSearch (Char_t value) const
 
Int_t BSearch (Bool_t value) const
 
Bool_t FillIndexArray ()
 
Long_t GetRowSize ()
 
void QSort ()
 
void LearnTable ()
 
Int_t SelectSearch (Float_t value) const
 
Int_t SelectSearch (Int_t value) const
 
Int_t SelectSearch (ULong_t value) const
 
Int_t SelectSearch (Long_t value) const
 
Int_t SelectSearch (UInt_t value) const
 
Int_t SelectSearch (Short_t value) const
 
Int_t SelectSearch (Double_t value) const
 
Int_t SelectSearch (UShort_t value) const
 
Int_t SelectSearch (UChar_t value) const
 
Int_t SelectSearch (Char_t value) const
 
Int_t SelectSearch (Bool_t value) const
 
void SetSearchMethod ()
 Select search function at once.
 
void SetSimpleArray (Int_t arraySize, Int_t firstRow, Int_t numberRows)
 Set some common parameteres for the "simple" arrays.
 
void BuildSorter (TString &colName, Int_t firstRow, Int_t numberRows)
 
const char * At (Int_t i) const
 

Static Protected Member Functions

static int CompareFloat_t (const void **, const void **)
 pointer to the internal array of TTable object;
 
static int CompareInt_t (const void **, const void **)
 
static int CompareLong_t (const void **, const void **)
 
static int CompareULong_t (const void **, const void **)
 
static int CompareUInt_t (const void **, const void **)
 
static int CompareShort_t (const void **, const void **)
 
static int CompareDouble_t (const void **, const void **)
 
static int CompareUShort_t (const void **, const void **)
 
static int CompareUChar_t (const void **, const void **)
 
static int CompareChar_t (const void **, const void **)
 
static int CompareBool_t (const void **, const void **)
 
static int SearchFloat_t (const void *, const void **)
 
static int SearchInt_t (const void *, const void **)
 
static int SearchULong_t (const void *, const void **)
 
static int SearchLong_t (const void *, const void **)
 
static int SearchUInt_t (const void *, const void **)
 
static int SearchShort_t (const void *, const void **)
 
static int SearchDouble_t (const void *, const void **)
 
static int SearchUShort_t (const void *, const void **)
 
static int SearchUChar_t (const void *, const void **)
 
static int SearchChar_t (const void *, const void **)
 
static int SearchBool_t (const void *, const void **)
 

Protected Attributes

void ** fSortIndex
 
Int_t fLastFound
 
Int_t fFirstRow
 
Int_t fNumberOfRows
 
TString fColName
 
Int_t fColOffset
 
Int_t fColSize
 
Int_t * fIndexArray
 
Int_t fColDimensions
 
const Char_t * fsimpleArray
 
const TTablefParentTable
 
SEARCHMETHOD fSearchMethod
 
COMPAREMETHOD fCompareMethod
 
TTable::EColumnType fColType
 
Long_t fParentRowSize
 
const char * fFirstParentRow
 

Detailed Description

Definition at line 46 of file TTableSorter.h.

Constructor & Destructor Documentation

TTableSorter::TTableSorter ( const TTable table,
TString &  colName,
Int_t  firstRow = 0,
Int_t  numberRows = 0 
)

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

Definition at line 117 of file TTableSorter.cxx.

References BuildSorter(), and fSearchMethod.

TTableSorter::TTableSorter ( const TTable table,
TString &  colName,
Int_t  firstRow = 0,
Int_t  numberRows = 0 
)

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

Definition at line 138 of file TTableSorter.cxx.

References BuildSorter(), and fSearchMethod.

TTableSorter::TTableSorter ( const TTable table,
SEARCHMETHOD  search,
COMPAREMETHOD  compare,
Int_t  firstRow = 0,
Int_t  numberRows = 0 
)

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.

Definition at line 165 of file TTableSorter.cxx.

References BuildSorter(), and fSearchMethod.

TTableSorter::TTableSorter ( const TTable table,
SEARCHMETHOD  search,
COMPAREMETHOD  compare,
Int_t  firstRow = 0,
Int_t  numberRows = 0 
)

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.

Definition at line 193 of file TTableSorter.cxx.

References BuildSorter(), and fSearchMethod.

TTableSorter::TTableSorter ( const Float_t *  simpleArray,
Int_t  arraySize,
Int_t  firstRow = 0,
Int_t  numberRows = 0 
)

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

Definition at line 300 of file TTableSorter.cxx.

References QSort(), SetSearchMethod(), and SetSimpleArray().

TTableSorter::TTableSorter ( const Double_t *  simpleArray,
Int_t  arraySize,
Int_t  firstRow = 0,
Int_t  numberRows = 0 
)

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

Definition at line 344 of file TTableSorter.cxx.

References QSort(), SetSearchMethod(), and SetSimpleArray().

TTableSorter::TTableSorter ( const Long_t *  simpleArray,
Int_t  arraySize,
Int_t  firstRow = 0,
Int_t  numberRows = 0 
)

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

Definition at line 388 of file TTableSorter.cxx.

References QSort(), SetSearchMethod(), and SetSimpleArray().

Member Function Documentation

void TTableSorter::BuildSorter ( TString &  colName,
Int_t  firstRow,
Int_t  numberRows 
)
protected

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

Definition at line 215 of file TTableSorter.cxx.

References FillIndexArray(), TTable::GetNRows(), TTable::GetRowSize(), LearnTable(), QSort(), and SetSearchMethod().

Referenced by TTableSorter().

Int_t TTableSorter::CountKey ( const void *  key,
Int_t  firstIndx = 0,
Bool_t  bSearch = kTRUE,
Int_t *  firstRow = 0 
) const
virtual

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

Definition at line 692 of file TTableSorter.cxx.

References FindFirstKey(), and fSearchMethod.

Referenced by TTableIter::CountKey(), CountKeys(), and TTablePoints::TTablePoints().

Int_t TTableSorter::CountKeys ( ) const
virtual

Counts the number of different key values

Definition at line 723 of file TTableSorter.cxx.

References CountKey().

Bool_t TTableSorter::FillIndexArray ( )
protected

File the array of the pointers and check whether the original table has been sorted to avoid an extra job.

Return: kTRUE - the table has been sorted kFALSE - otherwise

Definition at line 747 of file TTableSorter.cxx.

Referenced by BuildSorter().

Int_t TTableSorter::FindFirstKey ( const void *  key) const
virtual

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))

Definition at line 779 of file TTableSorter.cxx.

References BSearch(), and fSearchMethod.

Referenced by CountKey().

void TTableSorter::LearnTable ( )
protected

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)

Definition at line 901 of file TTableSorter.cxx.

References TTable::GetRowClass(), and TTable::Print().

Referenced by BuildSorter().

void TTableSorter::QSort ( )
protected

Call the standard C run-time library "qsort" function

Definition at line 884 of file TTableSorter.cxx.

Referenced by BuildSorter(), and TTableSorter().

Member Data Documentation

SEARCHMETHOD TTableSorter::fSearchMethod
protected
  • the back pointer to the sorted table

Definition at line 72 of file TTableSorter.h.

Referenced by BSearch(), CountKey(), FindFirstKey(), SetSearchMethod(), SetSimpleArray(), and TTableSorter().


The documentation for this class was generated from the following files: