]> git.uio.no Git - u/mrichter/AliRoot.git/blame - CONTAINERS/TArrayOfArray.cxx
Removing PYTHIA
[u/mrichter/AliRoot.git] / CONTAINERS / TArrayOfArray.cxx
CommitLineData
08edbb90 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
70479d0e 18Revision 1.2 2001/01/10 09:32:50 kowal2
19Changes to obey the coding rules.
20
633d3715 21Revision 1.1 2000/11/01 16:01:26 kowal2
22Classes for handling the new hits structures
23
08edbb90 24*/
25#include "TArrayOfArray.h"
70479d0e 26#include "Riostream.h"
08edbb90 27
28
29
30
31ClassImp(TArrayOfArray)
633d3715 32ClassImp(TArrayOfArrayVStack)
33ClassImp(TArrayOfArrayVList)
08edbb90 34
35
633d3715 36TArrayOfArrayVStack::TArrayOfArrayVStack()
08edbb90 37{
38 fIndex = 0;
39 fArray = 0;
40}
41
633d3715 42TArrayOfArrayVStack::TArrayOfArrayVStack(const char *classname)
08edbb90 43{
44 fIndex = 0;
45 fArray = 0;
46 SetClass(classname);
47}
48
49
633d3715 50TArrayOfArrayVStack::~TArrayOfArrayVStack()
08edbb90 51{
52 if (fIndex) delete fIndex;
53 if (fArray) delete fArray;
54}
55
633d3715 56Bool_t TArrayOfArrayVStack::SetClass(const char * classname)
08edbb90 57{
58 //
59 //set class
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);
64}
65
66
633d3715 67void TArrayOfArrayVStack::Clear(Option_t *)
08edbb90 68{
69 //
70 // clear contents
633d3715 71 if (fIndex) fIndex->Clear();
72 if (fArray) fArray->Clear();
73 //if (fIndex) fIndex->Resize(0);
74 //if (fArray) fArray->Resize(0);
08edbb90 75
76}
77
633d3715 78void * TArrayOfArrayVStack::At(UInt_t index0, UInt_t index1)
08edbb90 79{
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);
85 else
86 return 0;
87}
633d3715 88void TArrayOfArrayVStack::Dump(UInt_t index0, UInt_t index1)
08edbb90 89{
90 void * p = At(index0,index1);
91 if ( (p) && fArray->GetClassInfo()) fArray->GetClassInfo()->ObjectDump(p);
92 else{
93 printf("Index %d,%d out of range\n",index0,index1);
94 cout<<flush;
95 }
96
97}
98
633d3715 99Int_t TArrayOfArrayVStack::Resize(Int_t index, UInt_t newsize)
08edbb90 100{
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;
107 }
108 else{
109 cout<<"out\n";
110 }
111 return 0;
112}
113
633d3715 114UInt_t TArrayOfArrayVStack::Push(UInt_t size)
08edbb90 115{
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);
121 if (index1==0) {
122 fIndex->Resize(2);
123 (*(Int_t*)fIndex->Unchecked1DAt(0))=0;
124 (*(Int_t*)fIndex->Unchecked1DAt(1))=size;
125 return 0;
126 }
127 else{
128 fIndex->Resize(index1+1);
129 (*(Int_t*)fIndex->Unchecked1DAt(index1))=indexa+size;
130 }
131 return index1-1;
132}
133
633d3715 134Int_t TArrayOfArrayVStack::ArraySize(UInt_t index)
08edbb90 135{
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));
139 else
140 return 0;
141}