]>
Commit | Line | Data |
---|---|---|
bea6b2a4 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | /* $Id:*/ | |
16 | //////////////////////////////////////////////// | |
17 | // Huffman classes for set:TPC // | |
18 | //////////////////////////////////////////////// | |
19 | //This file contains two classes and it implements | |
20 | //the Huffman algorithm for creating tables | |
21 | //used in the compression phase. | |
22 | //The class AliTPCHNode represents a node of the Huffman tree, while | |
23 | //the class AliTPCHTable represents a compression table | |
24 | ||
25 | #include "AliTPCHNode.h" | |
26 | ||
27 | ClassImp(AliTPCHNode) | |
28 | ||
29 | AliTPCHNode::AliTPCHNode(){ | |
30 | //Constructor | |
31 | fLeft=0; | |
32 | fRight=0; | |
33 | } | |
34 | ||
35 | ////////////////////////////////////////////////////////////////////////////// | |
36 | ||
37 | AliTPCHNode::AliTPCHNode(Int_t sym, Double_t freq){ | |
38 | //Standard constructor | |
39 | fSymbol=sym; | |
40 | fFrequency=freq; | |
41 | fLeft=0; | |
42 | fRight=0; | |
43 | } | |
44 | ||
45 | ////////////////////////////////////////////////////////////////////////////// | |
46 | ||
47 | AliTPCHNode::AliTPCHNode(const AliTPCHNode &source) | |
48 | :TObject(source){ | |
49 | //Copy Constructor | |
50 | if(&source == this) return; | |
51 | this->fSymbol = source.fSymbol; | |
52 | this->fFrequency = source.fFrequency; | |
53 | this->fLeft = source.fLeft; | |
54 | this->fRight = source.fRight; | |
55 | return; | |
56 | } | |
57 | ||
58 | ////////////////////////////////////////////////////////////////////////////// | |
59 | ||
60 | AliTPCHNode& AliTPCHNode::operator=(const AliTPCHNode &source){ | |
61 | //Assignment operator | |
62 | if(&source == this) return *this; | |
63 | this->fSymbol = source.fSymbol; | |
64 | this->fFrequency = source.fFrequency; | |
65 | this->fLeft = source.fLeft; | |
66 | this->fRight = source.fRight; | |
67 | return *this; | |
68 | } | |
69 | ||
70 | ////////////////////////////////////////////////////////////////////////////// | |
71 | ||
72 | Int_t AliTPCHNode::Compare(const TObject *obj)const{ | |
73 | //Function called by Sort method of TObjArray | |
74 | AliTPCHNode *node=(AliTPCHNode *)obj; | |
75 | Double_t f=fFrequency; | |
76 | Double_t fo=node->fFrequency; | |
77 | if (f<fo) return 1; | |
78 | else if (f>fo) return -1; | |
79 | else return 0; | |
80 | } | |
81 | ||
82 | ////////////////////////////////////////////////////////////////////////////// |