9#include "CompressionMap.h"
15 CompressionMap::CompressionMap() : fSize(0), fAllocatedSize(0), fCounter(0), fOldToNewIndex(nullptr), fNewToOldIndex(nullptr) {}
17 CompressionMap::CompressionMap(
const CompressionMap& other) :
18 TObject(other), fSize(other.fSize), fAllocatedSize(other.fAllocatedSize), fCounter(other.fCounter), fOldToNewIndex(nullptr) {
19 if (fAllocatedSize > 0) {
20 fOldToNewIndex =
new Int_t[fAllocatedSize];
21 fNewToOldIndex =
new Int_t[fAllocatedSize];
23 std::cout <<
"WARNING COPY MAP" << std::endl;
26 void CompressionMap::Reset(Int_t size) {
30 for (
int i = 0; i < fSize; i++) {
31 fOldToNewIndex[i] = -1;
35 void CompressionMap::Recalculate() {
36 for (
int i = 0; i < fSize; i++) {
37 if (fOldToNewIndex[i] == 0) {
38 fOldToNewIndex[i] = fCounter;
39 fNewToOldIndex[fCounter] = i;
45 void CompressionMap::CheckSize(Int_t size) {
46 if (fAllocatedSize <= size) {
47 Int_t newSize = size * 2;
48 if (fOldToNewIndex)
delete[] fOldToNewIndex;
49 if (fNewToOldIndex)
delete[] fNewToOldIndex;
50 fOldToNewIndex =
new Int_t[newSize];
51 fNewToOldIndex =
new Int_t[newSize];
52 fAllocatedSize = newSize;
56 CompressionMap::~CompressionMap() {
57 if (fOldToNewIndex)
delete[] fOldToNewIndex;
58 if (fNewToOldIndex)
delete[] fNewToOldIndex;