ROOT logo
// @(#)root/table:$Id: TTableMap.h 27657 2009-02-28 04:51:36Z pcanal $
// Author: Valery Fine(fine@bnl.gov)   01/03/2001

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * Copyright (C) 2001 [BNL] Brookhaven National Laboratory.              *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TTableMap
#define ROOT_TTableMap

#include "assert.h"
#include <vector>

#ifndef ROOT_TTable
#include "TTable.h"
#endif

//////////////////////////////////////////////////////
//
// Class TTableMap
// Iterator of the table with extra index array
//
//////////////////////////////////////////////////////


class TTableMap : public TObject
#ifndef __CINT__
 , public std::vector<Long_t>
#endif
{
protected:
   const TTable  *fTable;         // pointer to the refered TTable

public:

   TTableMap(const TTable *table=0);
   TTableMap(const TTableMap &map) : TObject(map)
#ifndef __CINT__
      , std::vector<Long_t>(map)
#endif
    , fTable(map.fTable)	{;}
   virtual ~TTableMap(){;}
   Bool_t  IsValid() const;
   Bool_t  IsFolder() const;
   void Push_back(Long_t next); // workaround for Cint
   const TTable *Table(){return fTable;}

   TTable::iterator Begin();
   TTable::iterator Begin() const;
   TTable::iterator End();
   TTable::iterator End()   const;

   ClassDef(TTableMap,1) // "Map" array for TTable object
};

//___________________________________________________________________________________________________________
inline  Bool_t TTableMap::IsValid() const
{
   // Check whether all "map" values do belong the table
   TTable::iterator i      = Begin();
   TTable::iterator finish = End();
   Int_t totalSize          = fTable->GetNRows();

   for (; i != finish; i++) {
       Long_t th = *i;
       if (  th == -1 || (0 <= th && th < totalSize) ) continue;
       return kFALSE;
   }
   return kTRUE;
}
//___________________________________________________________________________________________________________
inline TTable::iterator TTableMap::Begin()          { std::vector<Long_t>::iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);}
//___________________________________________________________________________________________________________
inline TTable::iterator TTableMap::Begin()    const { std::vector<Long_t>::const_iterator bMap = this->begin(); return TTable::iterator(*fTable, bMap);}
//___________________________________________________________________________________________________________
inline TTable::iterator TTableMap::End()            { std::vector<Long_t>::iterator eMap = this->end(); return TTable::iterator(*fTable, eMap);}
//___________________________________________________________________________________________________________
inline TTable::iterator TTableMap::End()      const { std::vector<Long_t>::const_iterator eMap = this->end();  return TTable::iterator(*fTable, eMap);}
//___________________________________________________________________________________________________________
inline Bool_t           TTableMap::IsFolder() const { return kTRUE;}
//___________________________________________________________________________________________________________
inline void             TTableMap::Push_back(Long_t next){ push_back(next); } // workaround for Cint


#endif
 TTableMap.h:1
 TTableMap.h:2
 TTableMap.h:3
 TTableMap.h:4
 TTableMap.h:5
 TTableMap.h:6
 TTableMap.h:7
 TTableMap.h:8
 TTableMap.h:9
 TTableMap.h:10
 TTableMap.h:11
 TTableMap.h:12
 TTableMap.h:13
 TTableMap.h:14
 TTableMap.h:15
 TTableMap.h:16
 TTableMap.h:17
 TTableMap.h:18
 TTableMap.h:19
 TTableMap.h:20
 TTableMap.h:21
 TTableMap.h:22
 TTableMap.h:23
 TTableMap.h:24
 TTableMap.h:25
 TTableMap.h:26
 TTableMap.h:27
 TTableMap.h:28
 TTableMap.h:29
 TTableMap.h:30
 TTableMap.h:31
 TTableMap.h:32
 TTableMap.h:33
 TTableMap.h:34
 TTableMap.h:35
 TTableMap.h:36
 TTableMap.h:37
 TTableMap.h:38
 TTableMap.h:39
 TTableMap.h:40
 TTableMap.h:41
 TTableMap.h:42
 TTableMap.h:43
 TTableMap.h:44
 TTableMap.h:45
 TTableMap.h:46
 TTableMap.h:47
 TTableMap.h:48
 TTableMap.h:49
 TTableMap.h:50
 TTableMap.h:51
 TTableMap.h:52
 TTableMap.h:53
 TTableMap.h:54
 TTableMap.h:55
 TTableMap.h:56
 TTableMap.h:57
 TTableMap.h:58
 TTableMap.h:59
 TTableMap.h:60
 TTableMap.h:61
 TTableMap.h:62
 TTableMap.h:63
 TTableMap.h:64
 TTableMap.h:65
 TTableMap.h:66
 TTableMap.h:67
 TTableMap.h:68
 TTableMap.h:69
 TTableMap.h:70
 TTableMap.h:71
 TTableMap.h:72
 TTableMap.h:73
 TTableMap.h:74
 TTableMap.h:75
 TTableMap.h:76
 TTableMap.h:77
 TTableMap.h:78
 TTableMap.h:79
 TTableMap.h:80
 TTableMap.h:81
 TTableMap.h:82
 TTableMap.h:83
 TTableMap.h:84
 TTableMap.h:85
 TTableMap.h:86
 TTableMap.h:87
 TTableMap.h:88
 TTableMap.h:89
 TTableMap.h:90