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.2 2001/01/10 09:32:50 kowal2
19 Changes to obey the coding rules.
21 Revision 1.1 2000/11/01 16:01:26 kowal2
22 Classes for handling the new hits structures
25 #include "TArrayOfArray.h"
26 #include "Riostream.h"
31 ClassImp(TArrayOfArray)
32 ClassImp(TArrayOfArrayVStack)
33 ClassImp(TArrayOfArrayVList)
36 TArrayOfArrayVStack::TArrayOfArrayVStack()
42 TArrayOfArrayVStack::TArrayOfArrayVStack(const char *classname)
50 TArrayOfArrayVStack::~TArrayOfArrayVStack()
52 if (fIndex) delete fIndex;
53 if (fArray) delete fArray;
56 Bool_t TArrayOfArrayVStack::SetClass(const char * classname)
60 if (fIndex==0) fIndex = new AliObjectArray("Int_t");
61 if (fArray==0) fArray = new AliObjectArray;
62 else fArray->Delete();
63 return fArray->SetClass(classname);
67 void TArrayOfArrayVStack::Clear(Option_t *)
71 if (fIndex) fIndex->Clear();
72 if (fArray) fArray->Clear();
73 //if (fIndex) fIndex->Resize(0);
74 //if (fArray) fArray->Resize(0);
78 void * TArrayOfArrayVStack::At(UInt_t index0, UInt_t index1)
80 //get pointer to the object
81 if ( (fIndex!=0) && (index0+1<fIndex->GetSize())
82 && ((*((UInt_t*)(fIndex->Unchecked1DAt(index0+1)))
83 >(*((UInt_t*)(fIndex->Unchecked1DAt(index0)))+index1)) ) )
84 return Unchecked1DAt(index0,index1);
88 void TArrayOfArrayVStack::Dump(UInt_t index0, UInt_t index1)
90 void * p = At(index0,index1);
91 if ( (p) && fArray->GetClassInfo()) fArray->GetClassInfo()->ObjectDump(p);
93 printf("Index %d,%d out of range\n",index0,index1);
99 Int_t TArrayOfArrayVStack::Resize(Int_t index, UInt_t newsize)
101 //expand array with index index to newsize
102 if (index<0) index = fIndex->GetSize()-2;
103 if ((UInt_t)index==(fIndex->GetSize()-2)){
104 Int_t arrindex = *((Int_t*)(fIndex->At(index)));
105 fArray->Resize(arrindex+newsize);
106 *(Int_t*)(fIndex->At(index+1)) = arrindex+newsize;
114 UInt_t TArrayOfArrayVStack::Push(UInt_t size)
116 //make new array with size - return starting index
117 if ( (fIndex==0) || (fArray==0)) return 0;
118 UInt_t index1 = fIndex->GetSize();
119 UInt_t indexa = fArray->GetSize();
120 fArray->Resize(indexa+size);
123 (*(Int_t*)fIndex->Unchecked1DAt(0))=0;
124 (*(Int_t*)fIndex->Unchecked1DAt(1))=size;
128 fIndex->Resize(index1+1);
129 (*(Int_t*)fIndex->Unchecked1DAt(index1))=indexa+size;
134 Int_t TArrayOfArrayVStack::ArraySize(UInt_t index)
136 //size if subarray with index index
137 if ( (fIndex) && fIndex->GetSize()>index+1)
138 return (*(Int_t*)fIndex->Unchecked1DAt(index+1))-(*(Int_t*)fIndex->Unchecked1DAt(index));