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 #include "TArrayOfArray.h"
19 #include "Riostream.h"
24 ClassImp(TArrayOfArray)
25 ClassImp(TArrayOfArrayVStack)
26 ClassImp(TArrayOfArrayVList)
29 TArrayOfArrayVStack::TArrayOfArrayVStack()
35 TArrayOfArrayVStack::TArrayOfArrayVStack(const char *classname)
43 TArrayOfArrayVStack::~TArrayOfArrayVStack()
45 if (fIndex) delete fIndex;
46 if (fArray) delete fArray;
49 Bool_t TArrayOfArrayVStack::SetClass(const char * classname)
53 if (fIndex==0) fIndex = new AliObjectArray("Int_t");
54 if (fArray==0) fArray = new AliObjectArray;
55 else fArray->Delete();
56 return fArray->SetClass(classname);
60 void TArrayOfArrayVStack::Clear(Option_t *)
64 if (fIndex) fIndex->Clear();
65 if (fArray) fArray->Clear();
66 //if (fIndex) fIndex->Resize(0);
67 //if (fArray) fArray->Resize(0);
71 void * TArrayOfArrayVStack::At(UInt_t index0, UInt_t index1)
73 //get pointer to the object
74 if ( (fIndex!=0) && (index0+1<fIndex->GetSize())
75 && ((*((UInt_t*)(fIndex->Unchecked1DAt(index0+1)))
76 >(*((UInt_t*)(fIndex->Unchecked1DAt(index0)))+index1)) ) )
77 return Unchecked1DAt(index0,index1);
81 void TArrayOfArrayVStack::Dump(UInt_t index0, UInt_t index1)
83 void * p = At(index0,index1);
84 if ( (p) && fArray->GetClassInfo()) fArray->GetClassInfo()->ObjectDump(p);
86 printf("Index %d,%d out of range\n",index0,index1);
92 Int_t TArrayOfArrayVStack::Resize(Int_t index, UInt_t newsize)
94 //expand array with index index to newsize
95 if (index<0) index = fIndex->GetSize()-2;
96 if ((UInt_t)index==(fIndex->GetSize()-2)){
97 Int_t arrindex = *((Int_t*)(fIndex->At(index)));
98 fArray->Resize(arrindex+newsize);
99 *(Int_t*)(fIndex->At(index+1)) = arrindex+newsize;
107 UInt_t TArrayOfArrayVStack::Push(UInt_t size)
109 //make new array with size - return starting index
110 if ( (fIndex==0) || (fArray==0)) return 0;
111 UInt_t index1 = fIndex->GetSize();
112 UInt_t indexa = fArray->GetSize();
113 fArray->Resize(indexa+size);
116 (*(Int_t*)fIndex->Unchecked1DAt(0))=0;
117 (*(Int_t*)fIndex->Unchecked1DAt(1))=size;
121 fIndex->Resize(index1+1);
122 (*(Int_t*)fIndex->Unchecked1DAt(index1))=indexa+size;
127 Int_t TArrayOfArrayVStack::ArraySize(UInt_t index)
129 //size if subarray with index index
130 if ( (fIndex) && fIndex->GetSize()>index+1)
131 return (*(Int_t*)fIndex->Unchecked1DAt(index+1))-(*(Int_t*)fIndex->Unchecked1DAt(index));