]> git.uio.no Git - u/mrichter/AliRoot.git/blame - CONTAINERS/TArrayOfArray.cxx
README updated (R.Barbera)
[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$
633d3715 18Revision 1.1 2000/11/01 16:01:26 kowal2
19Classes for handling the new hits structures
20
08edbb90 21*/
22#include "TArrayOfArray.h"
23#include "iostream.h"
24
25
26
27
28ClassImp(TArrayOfArray)
633d3715 29ClassImp(TArrayOfArrayVStack)
30ClassImp(TArrayOfArrayVList)
08edbb90 31
32
633d3715 33TArrayOfArrayVStack::TArrayOfArrayVStack()
08edbb90 34{
35 fIndex = 0;
36 fArray = 0;
37}
38
633d3715 39TArrayOfArrayVStack::TArrayOfArrayVStack(const char *classname)
08edbb90 40{
41 fIndex = 0;
42 fArray = 0;
43 SetClass(classname);
44}
45
46
633d3715 47TArrayOfArrayVStack::~TArrayOfArrayVStack()
08edbb90 48{
49 if (fIndex) delete fIndex;
50 if (fArray) delete fArray;
51}
52
633d3715 53Bool_t TArrayOfArrayVStack::SetClass(const char * classname)
08edbb90 54{
55 //
56 //set class
57 if (fIndex==0) fIndex = new AliObjectArray("Int_t");
58 if (fArray==0) fArray = new AliObjectArray;
59 else fArray->Delete();
60 return fArray->SetClass(classname);
61}
62
63
633d3715 64void TArrayOfArrayVStack::Clear(Option_t *)
08edbb90 65{
66 //
67 // clear contents
633d3715 68 if (fIndex) fIndex->Clear();
69 if (fArray) fArray->Clear();
70 //if (fIndex) fIndex->Resize(0);
71 //if (fArray) fArray->Resize(0);
08edbb90 72
73}
74
633d3715 75void * TArrayOfArrayVStack::At(UInt_t index0, UInt_t index1)
08edbb90 76{
77 //get pointer to the object
78 if ( (fIndex!=0) && (index0+1<fIndex->GetSize())
79 && ((*((UInt_t*)(fIndex->Unchecked1DAt(index0+1)))
80 >(*((UInt_t*)(fIndex->Unchecked1DAt(index0)))+index1)) ) )
81 return Unchecked1DAt(index0,index1);
82 else
83 return 0;
84}
633d3715 85void TArrayOfArrayVStack::Dump(UInt_t index0, UInt_t index1)
08edbb90 86{
87 void * p = At(index0,index1);
88 if ( (p) && fArray->GetClassInfo()) fArray->GetClassInfo()->ObjectDump(p);
89 else{
90 printf("Index %d,%d out of range\n",index0,index1);
91 cout<<flush;
92 }
93
94}
95
633d3715 96Int_t TArrayOfArrayVStack::Resize(Int_t index, UInt_t newsize)
08edbb90 97{
98 //expand array with index index to newsize
99 if (index<0) index = fIndex->GetSize()-2;
100 if ((UInt_t)index==(fIndex->GetSize()-2)){
101 Int_t arrindex = *((Int_t*)(fIndex->At(index)));
102 fArray->Resize(arrindex+newsize);
103 *(Int_t*)(fIndex->At(index+1)) = arrindex+newsize;
104 }
105 else{
106 cout<<"out\n";
107 }
108 return 0;
109}
110
633d3715 111UInt_t TArrayOfArrayVStack::Push(UInt_t size)
08edbb90 112{
113 //make new array with size - return starting index
114 if ( (fIndex==0) || (fArray==0)) return 0;
115 UInt_t index1 = fIndex->GetSize();
116 UInt_t indexa = fArray->GetSize();
117 fArray->Resize(indexa+size);
118 if (index1==0) {
119 fIndex->Resize(2);
120 (*(Int_t*)fIndex->Unchecked1DAt(0))=0;
121 (*(Int_t*)fIndex->Unchecked1DAt(1))=size;
122 return 0;
123 }
124 else{
125 fIndex->Resize(index1+1);
126 (*(Int_t*)fIndex->Unchecked1DAt(index1))=indexa+size;
127 }
128 return index1-1;
129}
130
633d3715 131Int_t TArrayOfArrayVStack::ArraySize(UInt_t index)
08edbb90 132{
133 //size if subarray with index index
134 if ( (fIndex) && fIndex->GetSize()>index+1)
135 return (*(Int_t*)fIndex->Unchecked1DAt(index+1))-(*(Int_t*)fIndex->Unchecked1DAt(index));
136 else
137 return 0;
138}