ROOT logo
// @(#)root/cont:$Id: TArrayL64.cxx 20882 2007-11-19 11:31:26Z rdm $
// Author: Fons Rademakers   20/11/06

/*************************************************************************
 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TArrayL64                                                            //
//                                                                      //
// Array of long64s (64 bits per element).                              //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TArrayL64.h"
#include "TBuffer.h"


ClassImp(TArrayL64)

//______________________________________________________________________________
TArrayL64::TArrayL64()
{
   // Default TArrayL64 ctor.

   fArray = 0;
}

//______________________________________________________________________________
TArrayL64::TArrayL64(Int_t n)
{
   // Create TArrayL64 object and set array size to n long64s.

   fArray = 0;
   if (n > 0) Set(n);
}

//______________________________________________________________________________
TArrayL64::TArrayL64(Int_t n, const Long64_t *array)
{
   // Create TArrayL object and initialize it with values of array.

   fArray = 0;
   Set(n, array);
}

//______________________________________________________________________________
TArrayL64::TArrayL64(const TArrayL64 &array) : TArray(array)
{
   // Copy constructor.

   fArray = 0;
   Set(array.fN, array.fArray);
}

//______________________________________________________________________________
TArrayL64 &TArrayL64::operator=(const TArrayL64 &rhs)
{
   // TArrayL64 assignment operator.

   if (this != &rhs)
      Set(rhs.fN, rhs.fArray);
   return *this;
}

//______________________________________________________________________________
TArrayL64::~TArrayL64()
{
   // Delete TArrayL64 object.

   delete [] fArray;
   fArray = 0;
}

//______________________________________________________________________________
void TArrayL64::Adopt(Int_t n, Long64_t *arr)
{
   // Adopt array arr into TArrayL64, i.e. don't copy arr but use it directly
   // in TArrayL64. User may not delete arr, TArrayL64 dtor will do it.

   if (fArray)
      delete [] fArray;

   fN     = n;
   fArray = arr;
}

//______________________________________________________________________________
void TArrayL64::AddAt(Long64_t c, Int_t i)
{
   // Add long64 c at position i. Check for out of bounds.

   if (!BoundsOk("TArrayL64::AddAt", i)) return;
   fArray[i] = c;
}

//______________________________________________________________________________
void TArrayL64::Set(Int_t n)
{
   // Set size of this array to n long64s.
   // A new array is created, the old contents copied to the new array,
   // then the old array is deleted.
   // This function should not be called if the array was declared via Adopt.

   if (n < 0) return;
   if (n != fN) {
      Long64_t *temp = fArray;
      if (n != 0) {
         fArray = new Long64_t[n];
         if (n < fN) memcpy(fArray,temp, n*sizeof(Long64_t));
         else {
            memcpy(fArray,temp,fN*sizeof(Long64_t));
            memset(&fArray[fN],0,(n-fN)*sizeof(Long64_t));
         }
      } else {
         fArray = 0;
      }
      if (fN) delete [] temp;
      fN = n;
   }
}

//______________________________________________________________________________
void TArrayL64::Set(Int_t n, const Long64_t *array)
{
   // Set size of this array to n long64s and set the contents.
   // This function should not be called if the array was declared via Adopt.

   if (fArray && fN != n) {
      delete [] fArray;
      fArray = 0;
   }
   fN = n;
   if (fN == 0) return;
   if (array == 0) return;
   if (!fArray) fArray = new Long64_t[fN];
   memcpy(fArray,array, n*sizeof(Long64_t));
}

//_______________________________________________________________________
void TArrayL64::Streamer(TBuffer &b)
{
   // Stream a TArrayL64 object.

   if (b.IsReading()) {
      Int_t n;
      b >> n;
      Set(n);
      b.ReadFastArray(fArray,n);
   } else {
      b << fN;
      b.WriteFastArray(fArray, fN);
   }
}
 TArrayL64.cxx:1
 TArrayL64.cxx:2
 TArrayL64.cxx:3
 TArrayL64.cxx:4
 TArrayL64.cxx:5
 TArrayL64.cxx:6
 TArrayL64.cxx:7
 TArrayL64.cxx:8
 TArrayL64.cxx:9
 TArrayL64.cxx:10
 TArrayL64.cxx:11
 TArrayL64.cxx:12
 TArrayL64.cxx:13
 TArrayL64.cxx:14
 TArrayL64.cxx:15
 TArrayL64.cxx:16
 TArrayL64.cxx:17
 TArrayL64.cxx:18
 TArrayL64.cxx:19
 TArrayL64.cxx:20
 TArrayL64.cxx:21
 TArrayL64.cxx:22
 TArrayL64.cxx:23
 TArrayL64.cxx:24
 TArrayL64.cxx:25
 TArrayL64.cxx:26
 TArrayL64.cxx:27
 TArrayL64.cxx:28
 TArrayL64.cxx:29
 TArrayL64.cxx:30
 TArrayL64.cxx:31
 TArrayL64.cxx:32
 TArrayL64.cxx:33
 TArrayL64.cxx:34
 TArrayL64.cxx:35
 TArrayL64.cxx:36
 TArrayL64.cxx:37
 TArrayL64.cxx:38
 TArrayL64.cxx:39
 TArrayL64.cxx:40
 TArrayL64.cxx:41
 TArrayL64.cxx:42
 TArrayL64.cxx:43
 TArrayL64.cxx:44
 TArrayL64.cxx:45
 TArrayL64.cxx:46
 TArrayL64.cxx:47
 TArrayL64.cxx:48
 TArrayL64.cxx:49
 TArrayL64.cxx:50
 TArrayL64.cxx:51
 TArrayL64.cxx:52
 TArrayL64.cxx:53
 TArrayL64.cxx:54
 TArrayL64.cxx:55
 TArrayL64.cxx:56
 TArrayL64.cxx:57
 TArrayL64.cxx:58
 TArrayL64.cxx:59
 TArrayL64.cxx:60
 TArrayL64.cxx:61
 TArrayL64.cxx:62
 TArrayL64.cxx:63
 TArrayL64.cxx:64
 TArrayL64.cxx:65
 TArrayL64.cxx:66
 TArrayL64.cxx:67
 TArrayL64.cxx:68
 TArrayL64.cxx:69
 TArrayL64.cxx:70
 TArrayL64.cxx:71
 TArrayL64.cxx:72
 TArrayL64.cxx:73
 TArrayL64.cxx:74
 TArrayL64.cxx:75
 TArrayL64.cxx:76
 TArrayL64.cxx:77
 TArrayL64.cxx:78
 TArrayL64.cxx:79
 TArrayL64.cxx:80
 TArrayL64.cxx:81
 TArrayL64.cxx:82
 TArrayL64.cxx:83
 TArrayL64.cxx:84
 TArrayL64.cxx:85
 TArrayL64.cxx:86
 TArrayL64.cxx:87
 TArrayL64.cxx:88
 TArrayL64.cxx:89
 TArrayL64.cxx:90
 TArrayL64.cxx:91
 TArrayL64.cxx:92
 TArrayL64.cxx:93
 TArrayL64.cxx:94
 TArrayL64.cxx:95
 TArrayL64.cxx:96
 TArrayL64.cxx:97
 TArrayL64.cxx:98
 TArrayL64.cxx:99
 TArrayL64.cxx:100
 TArrayL64.cxx:101
 TArrayL64.cxx:102
 TArrayL64.cxx:103
 TArrayL64.cxx:104
 TArrayL64.cxx:105
 TArrayL64.cxx:106
 TArrayL64.cxx:107
 TArrayL64.cxx:108
 TArrayL64.cxx:109
 TArrayL64.cxx:110
 TArrayL64.cxx:111
 TArrayL64.cxx:112
 TArrayL64.cxx:113
 TArrayL64.cxx:114
 TArrayL64.cxx:115
 TArrayL64.cxx:116
 TArrayL64.cxx:117
 TArrayL64.cxx:118
 TArrayL64.cxx:119
 TArrayL64.cxx:120
 TArrayL64.cxx:121
 TArrayL64.cxx:122
 TArrayL64.cxx:123
 TArrayL64.cxx:124
 TArrayL64.cxx:125
 TArrayL64.cxx:126
 TArrayL64.cxx:127
 TArrayL64.cxx:128
 TArrayL64.cxx:129
 TArrayL64.cxx:130
 TArrayL64.cxx:131
 TArrayL64.cxx:132
 TArrayL64.cxx:133
 TArrayL64.cxx:134
 TArrayL64.cxx:135
 TArrayL64.cxx:136
 TArrayL64.cxx:137
 TArrayL64.cxx:138
 TArrayL64.cxx:139
 TArrayL64.cxx:140
 TArrayL64.cxx:141
 TArrayL64.cxx:142
 TArrayL64.cxx:143
 TArrayL64.cxx:144
 TArrayL64.cxx:145
 TArrayL64.cxx:146
 TArrayL64.cxx:147
 TArrayL64.cxx:148
 TArrayL64.cxx:149
 TArrayL64.cxx:150
 TArrayL64.cxx:151
 TArrayL64.cxx:152
 TArrayL64.cxx:153
 TArrayL64.cxx:154
 TArrayL64.cxx:155
 TArrayL64.cxx:156
 TArrayL64.cxx:157
 TArrayL64.cxx:158
 TArrayL64.cxx:159