]> git.uio.no Git - u/mrichter/AliRoot.git/blame - CONTAINERS/TArrayOfArray.cxx
Clear method modified to fix the problem with reading Tree.
[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$
18*/
19#include "TArrayOfArray.h"
20#include "iostream.h"
21
22
23
24
25ClassImp(TArrayOfArray)
26ClassImp(TArrayOfArray_vStack)
27ClassImp(TArrayOfArray_vList)
28
29
30TArrayOfArray_vStack::TArrayOfArray_vStack()
31{
32 fIndex = 0;
33 fArray = 0;
34}
35
36TArrayOfArray_vStack::TArrayOfArray_vStack(const char *classname)
37{
38 fIndex = 0;
39 fArray = 0;
40 SetClass(classname);
41}
42
43
44TArrayOfArray_vStack::~TArrayOfArray_vStack()
45{
46 if (fIndex) delete fIndex;
47 if (fArray) delete fArray;
48}
49
50Bool_t TArrayOfArray_vStack::SetClass(const char * classname)
51{
52 //
53 //set class
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);
58}
59
60
61void TArrayOfArray_vStack::Clear(Option_t *)
62{
63 //
64 // clear contents
65 //if (fIndex) fIndex->Clear();
66 //if (fArray) fArray->Clear();
67 if (fIndex) fIndex->Resize(0);
68 if (fArray) fArray->Resize(0);
69
70}
71
72void * TArrayOfArray_vStack::At(UInt_t index0, UInt_t index1)
73{
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);
79 else
80 return 0;
81}
82void TArrayOfArray_vStack::Dump(UInt_t index0, UInt_t index1)
83{
84 void * p = At(index0,index1);
85 if ( (p) && fArray->GetClassInfo()) fArray->GetClassInfo()->ObjectDump(p);
86 else{
87 printf("Index %d,%d out of range\n",index0,index1);
88 cout<<flush;
89 }
90
91}
92
93Int_t TArrayOfArray_vStack::Resize(Int_t index, UInt_t newsize)
94{
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;
101 }
102 else{
103 cout<<"out\n";
104 }
105 return 0;
106}
107
108UInt_t TArrayOfArray_vStack::Push(UInt_t size)
109{
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);
115 if (index1==0) {
116 fIndex->Resize(2);
117 (*(Int_t*)fIndex->Unchecked1DAt(0))=0;
118 (*(Int_t*)fIndex->Unchecked1DAt(1))=size;
119 return 0;
120 }
121 else{
122 fIndex->Resize(index1+1);
123 (*(Int_t*)fIndex->Unchecked1DAt(index1))=indexa+size;
124 }
125 return index1-1;
126}
127
128Int_t TArrayOfArray_vStack::ArraySize(UInt_t index)
129{
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));
133 else
134 return 0;
135}