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