| 1 | #ifndef MARS_MLut
|
|---|
| 2 | #define MARS_MLut
|
|---|
| 3 |
|
|---|
| 4 | #ifndef ROOT_TObjArray
|
|---|
| 5 | #include <TObjArray.h>
|
|---|
| 6 | #endif
|
|---|
| 7 |
|
|---|
| 8 | #include <iosfwd>
|
|---|
| 9 |
|
|---|
| 10 | class MArrayI;
|
|---|
| 11 |
|
|---|
| 12 | class MLut : public TObjArray
|
|---|
| 13 | {
|
|---|
| 14 | private:
|
|---|
| 15 | UInt_t fMinEntries; // The minimum entries per row
|
|---|
| 16 | UInt_t fMaxEntries; // The maximum entries per row
|
|---|
| 17 |
|
|---|
| 18 | Int_t fMaxIndex; // The maximum index fount in the lut
|
|---|
| 19 |
|
|---|
| 20 | MLut *GetInverse(Bool_t uniq=kTRUE) const;
|
|---|
| 21 |
|
|---|
| 22 | public:
|
|---|
| 23 | MLut() : fMinEntries(0), fMaxEntries(0), fMaxIndex(0) { SetOwner(); }
|
|---|
| 24 |
|
|---|
| 25 | // TObjArry
|
|---|
| 26 | void Delete(Option_t *option="");
|
|---|
| 27 |
|
|---|
| 28 | // MLut Getter
|
|---|
| 29 | const MArrayI &GetRow(UInt_t i) const;
|
|---|
| 30 |
|
|---|
| 31 | Int_t GetNumRows() const { return GetEntriesFast(); }
|
|---|
| 32 |
|
|---|
| 33 | UInt_t GetMaxEntries() const { return fMaxEntries; }
|
|---|
| 34 | Int_t GetMaxIndex() const { return fMaxIndex; }
|
|---|
| 35 |
|
|---|
| 36 | Bool_t HasConstantLength() const { return fMinEntries==fMaxEntries; }
|
|---|
| 37 | Bool_t IsEmpty() const { return fMaxEntries==0; }
|
|---|
| 38 | Bool_t IsDefaultCol() const;
|
|---|
| 39 | Bool_t IsDefaultRow() const;
|
|---|
| 40 |
|
|---|
| 41 | // MLut conversions
|
|---|
| 42 | void SetInverse(const MLut &lut, Bool_t uniq=kTRUE);
|
|---|
| 43 | void Invert(Bool_t uniq=kTRUE);
|
|---|
| 44 |
|
|---|
| 45 | // Setter
|
|---|
| 46 | void SetDefaultCol(UInt_t n);
|
|---|
| 47 | void SetDefaultRow(UInt_t n);
|
|---|
| 48 |
|
|---|
| 49 | // MLut I/O
|
|---|
| 50 | Int_t ReadStream(std::istream &in);
|
|---|
| 51 | Int_t WriteStream(std::ostream &out) const;
|
|---|
| 52 |
|
|---|
| 53 | Int_t ReadFile(const char *fname);
|
|---|
| 54 | Int_t WriteFile(const char *fname) const;
|
|---|
| 55 |
|
|---|
| 56 | // TObject
|
|---|
| 57 | void Print(const Option_t *o="") const;
|
|---|
| 58 | void Print(const Option_t *o, Option_t *) const { Print(o); }
|
|---|
| 59 | void Print(const Option_t *o, Int_t) const { Print(o); }
|
|---|
| 60 | void Print(const Option_t *o, const char*, Int_t) const { Print(o); }
|
|---|
| 61 | void Print(const Option_t *o, TPRegexp&, Int_t) const { Print(o); }
|
|---|
| 62 |
|
|---|
| 63 | ClassDef(MLut, 1) // A simple and fast easy-to-use look-up-table
|
|---|
| 64 | };
|
|---|
| 65 |
|
|---|
| 66 | #endif
|
|---|