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 **************************************************************************/
19 #include "TArrayOfArray.h"
25 ClassImp(TArrayOfArray)
26 ClassImp(TArrayOfArray_vStack)
27 ClassImp(TArrayOfArray_vList)
30 TArrayOfArray_vStack::TArrayOfArray_vStack()
36 TArrayOfArray_vStack::TArrayOfArray_vStack(const char *classname)
44 TArrayOfArray_vStack::~TArrayOfArray_vStack()
46 if (fIndex) delete fIndex;
47 if (fArray) delete fArray;
50 Bool_t TArrayOfArray_vStack::SetClass(const char * classname)
54 if (fIndex==0) fIndex = new AliObjectArray("Int_t");
55 if (fArray==0) fArray = new AliObjectArray;
56 else fArray->Delete();
57 return fArray->SetClass(classname);
61 void TArrayOfArray_vStack::Clear(Option_t *)
65 //if (fIndex) fIndex->Clear();
66 //if (fArray) fArray->Clear();
67 if (fIndex) fIndex->Resize(0);
68 if (fArray) fArray->Resize(0);
72 void * TArrayOfArray_vStack::At(UInt_t index0, UInt_t index1)
74 //get pointer to the object
75 if ( (fIndex!=0) && (index0+1<fIndex->GetSize())
76 && ((*((UInt_t*)(fIndex->Unchecked1DAt(index0+1)))
77 >(*((UInt_t*)(fIndex->Unchecked1DAt(index0)))+index1)) ) )
78 return Unchecked1DAt(index0,index1);
82 void TArrayOfArray_vStack::Dump(UInt_t index0, UInt_t index1)
84 void * p = At(index0,index1);
85 if ( (p) && fArray->GetClassInfo()) fArray->GetClassInfo()->ObjectDump(p);
87 printf("Index %d,%d out of range\n",index0,index1);
93 Int_t TArrayOfArray_vStack::Resize(Int_t index, UInt_t newsize)
95 //expand array with index index to newsize
96 if (index<0) index = fIndex->GetSize()-2;
97 if ((UInt_t)index==(fIndex->GetSize()-2)){
98 Int_t arrindex = *((Int_t*)(fIndex->At(index)));
99 fArray->Resize(arrindex+newsize);
100 *(Int_t*)(fIndex->At(index+1)) = arrindex+newsize;
108 UInt_t TArrayOfArray_vStack::Push(UInt_t size)
110 //make new array with size - return starting index
111 if ( (fIndex==0) || (fArray==0)) return 0;
112 UInt_t index1 = fIndex->GetSize();
113 UInt_t indexa = fArray->GetSize();
114 fArray->Resize(indexa+size);
117 (*(Int_t*)fIndex->Unchecked1DAt(0))=0;
118 (*(Int_t*)fIndex->Unchecked1DAt(1))=size;
122 fIndex->Resize(index1+1);
123 (*(Int_t*)fIndex->Unchecked1DAt(index1))=indexa+size;
128 Int_t TArrayOfArray_vStack::ArraySize(UInt_t index)
130 //size if subarray with index index
131 if ( (fIndex) && fIndex->GetSize()>index+1)
132 return (*(Int_t*)fIndex->Unchecked1DAt(index+1))-(*(Int_t*)fIndex->Unchecked1DAt(index));