Changeset 1629 for trunk/MagicSoft/Mars/mhist/MFillH.cc
- Timestamp:
- 11/18/02 10:46:48 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MFillH.cc
r1574 r1629 85 85 ClassImp(MFillH); 86 86 87 //////////////////////////////////////////////////////////////////////////////88 //89 // MMap90 //91 // This class maps a key-value to a given value. In its simple versions it92 // maps a key to an index.93 //94 //////////////////////////////////////////////////////////////////////////////95 #include <TArrayI.h>96 97 class MMap98 {99 private:100 TArrayI fKeys;101 TArrayI fValues;102 103 Int_t K(Int_t i) const { return ((TArrayI)fKeys)[i]; }104 Int_t V(Int_t i) const { return ((TArrayI)fValues)[i]; }105 106 public:107 // --------------------------------------------------------------------------108 //109 // Get the value which corresponds to the given key-value110 //111 Int_t GetValue(Int_t key) const112 {113 const Int_t n = fKeys.GetSize();114 for (int i=0; i<n; i++)115 {116 if (K(i)==key)117 return V(i);118 }119 return -1;120 }121 122 // --------------------------------------------------------------------------123 //124 // Adds a new pair key-value. While the key is the key to the value.125 // if the key already exists the pair is ignored.126 //127 void Add(Int_t key, Int_t value)128 {129 if (GetValue(key)>=0)130 return;131 132 const Int_t n = fKeys.GetSize();133 134 fKeys.Set(n+1);135 fValues.Set(n+1);136 137 fKeys[n] = key;138 fValues[n] = value;139 }140 141 // --------------------------------------------------------------------------142 //143 // Adds a new pair key-value. While the key is the key to the value.144 // In this case the value is an automatically sequential created index.145 // if the key already exists the pair is ignored.146 //147 Int_t Add(Int_t key)148 {149 const Int_t k = GetValue(key);150 if (k>=0)151 return k;152 153 const Int_t n = fKeys.GetSize();154 155 fKeys.Set(n+1);156 fValues.Set(n+1);157 158 fKeys[n] = key;159 fValues[n] = n;160 161 return n;162 }163 };164 165 87 // -------------------------------------------------------------------------- 166 88 // … … 177 99 178 100 fIndex = NULL; 179 fMapIdx = new MMap;180 101 } 181 102 … … 326 247 if (fIndex->TestBit(kCanDelete)) 327 248 delete fIndex; 328 329 delete fMapIdx;330 249 } 331 250 … … 500 419 { 501 420 if (fIndex) 502 { 503 const Int_t key = (Int_t)fIndex->GetValue(); 504 const Int_t idx = fMapIdx->Add(key); 505 ((MHArray*)fH)->SetIndex(idx); 506 } 421 ((MHArray*)fH)->SetIndexByKey(fIndex->GetValue()); 422 /* 423 const Int_t key = (Int_t)fIndex->GetValue(); 424 const Int_t idx = fMapIdx->Add(key); 425 ((MHArray*)fH)->SetIndex(idx); 426 */ 507 427 508 428 return fH->Fill(fParContainer);
Note:
See TracChangeset
for help on using the changeset viewer.