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