]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSHuffman.h
- Volume name attribute replaced with volume path
[u/mrichter/AliRoot.git] / ITS / AliITSHuffman.h
1 #ifndef AliITSHUFFMAN_H
2 #define AliITSHUFFMAN_H
3
4 ///////////////////////////////////////////////////
5 //  Huffman Table associated classes for set:ITS //
6 ///////////////////////////////////////////////////
7
8 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9 // Attention! Two classes in this file.
10 // They have to stay in the same file.
11 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12
13 #include <TObject.h>
14
15 class AliITSInStream;
16 class TObjectArray;
17 class AliITSHNode: public TObject  {
18
19  public:
20   AliITSHNode();
21   AliITSHNode(UChar_t symbol, ULong_t freq);
22   virtual   ~AliITSHNode() {
23     // destructor
24   }
25   AliITSHNode(const AliITSHNode &source); // copy constructor
26   AliITSHNode& operator=(const AliITSHNode &source); // ass. op.
27
28   Bool_t IsSortable() const {
29     // is sortable
30     return kTRUE;
31   }
32   Int_t Compare(const TObject *obj) const;
33   
34   ClassDef(AliITSHNode,1)     //HuffT node object for set:ITS
35
36  public:
37
38   UChar_t    fSymbol;        // comment to be written
39   ULong_t    fFrequency;     // comment to be written
40   AliITSHNode     *fLeft;    // comment to be written
41   AliITSHNode     *fRight;   // comment to be written
42   AliITSHNode     *fFather;  // not used
43 };
44
45 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
46 //  Attention! Next class has kept deliberaty in 
47 //  the same file as the previous one
48 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
49 //___________________________________________
50 class AliITSHTable: public TObject{
51   
52 public:
53   AliITSHTable(); 
54   AliITSHTable(Int_t size);
55   virtual   ~AliITSHTable();
56   AliITSHTable(const AliITSHTable &source); // copy constructor
57   AliITSHTable& operator=(const AliITSHTable &source); // ass. op.
58   
59   Int_t  Size() {
60     // size
61     return fSize;
62   }
63   UChar_t   *CodeLen() {
64     // code len
65     return fCodeLen;
66   }
67   ULong_t *Code() {
68     // code
69     return fCode;
70   }
71   TObjArray  *HNodes() {
72     // HNodes
73     return fHNodes;
74   }
75   
76   
77   void GetFrequencies(Int_t len, UChar_t *stream);
78   void BuildHTable();   
79   Bool_t SpanTree(AliITSHNode*start, ULong_t code, UChar_t len);
80   void ResetHNodes();
81   void ClearTable();
82   
83  protected:
84
85   Int_t          fSize;     // size of the arrays
86   UChar_t       *fCodeLen;  //![fSize] number of bits array
87   ULong_t       *fCode;     //![fSize] coded symbols array
88   
89   Short_t       *fSym;      //![fSize] array of input symbols
90   TObjArray     *fHNodes;   // array of nodes
91   Int_t          fNnodes;   // number of nodes
92
93   ClassDef(AliITSHTable,1)     //Huffman Table  object for set:ITS
94     };
95
96 #endif