ROOT logo
#pragma interface
#ifndef HINDEXTABLE_H
#define HINDEXTABLE_H

#include "TObject.h"
#include "TArrayI.h"
#include "hlocation.h"
#include "TBuffer.h"

class HPairListI : public TObject {
 private:
  Int_t fCapacity;
  Int_t fN;
  UInt_t *fArray[2];
 public:
  HPairListI(void) {fCapacity=0; fN=0; fArray[0]=fArray[1]=0;}
  ~HPairListI(void) { if (fCapacity>0) {delete[] fArray[0]; delete[] fArray[1];} }
  void setCapacity(Int_t n);
  void add(UInt_t i1,UInt_t i2) {
  #if DEBUG_LEVEL==1
      if (fN<fCapacity) {
	  fArray[0][fN]=i1; fArray[1][fN]=i2;
	  fN++;
      }
  #else
      fArray[0][fN]=i1; fArray[1][fN]=i2;
      fN++;
  #endif
  }
  void set(Int_t index, UInt_t i1,UInt_t i2) {
    fArray[0][index]=i1; fArray[1][index]=i2;
  }
  void remove(Int_t idx);
  Int_t getN(void) {return fN;}
  UInt_t &getIndex1(Int_t idx) {return fArray[0][idx]; }
  UInt_t &getIndex2(Int_t idx) {return fArray[1][idx]; }
  void clear(Option_t *opt="") {fN=0;} // The default value of a pair is not
                                       // granted to be 0
  ClassDef(HPairListI,2)
};

class HIndexTable : public TObject {
protected:
  TArrayI fSizes; //Sizes of the dimensions of the index matrix
  HPairListI fCompactTable; //Table of linear addres -- index pairs
  TArrayI fIndexArray; //!Index matrix
  Int_t fCurrentPos; //!Current position in the table for iterations.
public:
  HIndexTable(void);
  ~HIndexTable(void);
  void setDimensions(Int_t nDim,Int_t *sizes);
  Int_t getIndex(HLocation &aLoc) { return (fIndexArray[aLoc.getLinearIndex(&fSizes)]); }
  void setIndex(HLocation &aLoc,Int_t idx) { 
    Int_t la=aLoc.getLinearIndex(&fSizes);
    fCompactTable.add(la,idx);
    fIndexArray[la]=idx; 
  }
  TArrayI *getDimensions(void) {return &fSizes;}
  inline Int_t getIndex(UInt_t linAddr) {
    return ((Int_t)linAddr >= fIndexArray.fN)?-1:fIndexArray.fArray[linAddr];
  }
  void setIndex(Int_t linAddr,Int_t idx) { 
    fIndexArray[linAddr]=idx; 
    fCompactTable.add(linAddr,idx); 
  }
  Int_t getEntries(void) { return fIndexArray.fN; }
  Bool_t checkLocation(HLocation &aLoc);
  Int_t gotoLocation(HLocation &aLoc);
  Int_t gotoBegin(void);
  Int_t next(void);
  void Clear(Option_t *opt="");
  HPairListI* getCompactTable(void) {return &fCompactTable;}
  ClassDef(HIndexTable,2) //Utility class handling an index table.
};

#endif /* !HINDEXTABLE_H */

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