1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.1 2000/11/01 16:01:26 kowal2
19 Classes for handling the new hits structures
22 #include "TArrayOfArray.h"
28 ClassImp(TArrayOfArray)
29 ClassImp(TArrayOfArrayVStack)
30 ClassImp(TArrayOfArrayVList)
33 TArrayOfArrayVStack::TArrayOfArrayVStack()
39 TArrayOfArrayVStack::TArrayOfArrayVStack(const char *classname)
47 TArrayOfArrayVStack::~TArrayOfArrayVStack()
49 if (fIndex) delete fIndex;
50 if (fArray) delete fArray;
53 Bool_t TArrayOfArrayVStack::SetClass(const char * classname)
57 if (fIndex==0) fIndex = new AliObjectArray("Int_t");
58 if (fArray==0) fArray = new AliObjectArray;
59 else fArray->Delete();
60 return fArray->SetClass(classname);
64 void TArrayOfArrayVStack::Clear(Option_t *)
68 if (fIndex) fIndex->Clear();
69 if (fArray) fArray->Clear();
70 //if (fIndex) fIndex->Resize(0);
71 //if (fArray) fArray->Resize(0);
75 void * TArrayOfArrayVStack::At(UInt_t index0, UInt_t index1)
77 //get pointer to the object
78 if ( (fIndex!=0) && (index0+1<fIndex->GetSize())
79 && ((*((UInt_t*)(fIndex->Unchecked1DAt(index0+1)))
80 >(*((UInt_t*)(fIndex->Unchecked1DAt(index0)))+index1)) ) )
81 return Unchecked1DAt(index0,index1);
85 void TArrayOfArrayVStack::Dump(UInt_t index0, UInt_t index1)
87 void * p = At(index0,index1);
88 if ( (p) && fArray->GetClassInfo()) fArray->GetClassInfo()->ObjectDump(p);
90 printf("Index %d,%d out of range\n",index0,index1);
96 Int_t TArrayOfArrayVStack::Resize(Int_t index, UInt_t newsize)
98 //expand array with index index to newsize
99 if (index<0) index = fIndex->GetSize()-2;
100 if ((UInt_t)index==(fIndex->GetSize()-2)){
101 Int_t arrindex = *((Int_t*)(fIndex->At(index)));
102 fArray->Resize(arrindex+newsize);
103 *(Int_t*)(fIndex->At(index+1)) = arrindex+newsize;
111 UInt_t TArrayOfArrayVStack::Push(UInt_t size)
113 //make new array with size - return starting index
114 if ( (fIndex==0) || (fArray==0)) return 0;
115 UInt_t index1 = fIndex->GetSize();
116 UInt_t indexa = fArray->GetSize();
117 fArray->Resize(indexa+size);
120 (*(Int_t*)fIndex->Unchecked1DAt(0))=0;
121 (*(Int_t*)fIndex->Unchecked1DAt(1))=size;
125 fIndex->Resize(index1+1);
126 (*(Int_t*)fIndex->Unchecked1DAt(index1))=indexa+size;
131 Int_t TArrayOfArrayVStack::ArraySize(UInt_t index)
133 //size if subarray with index index
134 if ( (fIndex) && fIndex->GetSize()>index+1)
135 return (*(Int_t*)fIndex->Unchecked1DAt(index+1))-(*(Int_t*)fIndex->Unchecked1DAt(index));