Files
geant4/source/global/STLInterface/g4rw/tvvector.icc
T
2016-06-08 16:10:37 +02:00

142 lines
4.0 KiB
Plaintext

//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: tvvector.icc,v 1.4.4.1 2001/06/28 19:09:59 gunter Exp $
// GEANT4 tag $Name: $
//
//
//---------------------------------------------------------------
// GEANT 4 class header file
//
// G4RWTValVector
//---------------------------------------------------------------
template<class T>
G4RWTValVector<T>::G4RWTValVector ()
: std_vector(), rwsize(0){}
template<class T>
G4RWTValVector<T>::G4RWTValVector (size_t n)
: std_vector(n,T()), rwsize(n){}
template<class T>
G4RWTValVector<T>::G4RWTValVector (size_t n, const T& ival)
: std_vector(n,ival), rwsize(n){}
template<class T>
G4RWTValVector<T>::G4RWTValVector (const G4RWTValVector<T>& ival)
: std_vector(ival), rwsize(ival.rwsize){}
template<class T>
G4RWTValVector<T>::~G4RWTValVector(){}
template<class T>
G4RWTValVector<T>&
G4RWTValVector<T>::operator= (const G4RWTValVector<T>& v)
{
std_vector::operator=(v);
rwsize=v.rwsize;
return *this;
}
template<class T>
size_t G4RWTValVector<T>::length() const
{
return std_vector::size();
}
template<class T>
T& G4RWTValVector<T>::operator()(size_t i)
{
// temporarly commented; to allow use as left-value rwsize is increased
// #ifdef G4DEBUG
// if(i>=rwsize)
// G4RWTHROW(G4RWBoundsErr("G4RWTValVector operator()",rwsize,i));
// #endif
if(rwsize<=i && i<std_vector::size())
rwsize=i+1;
return std_vector::operator[](i);
}
template<class T>
const T& G4RWTValVector<T>::operator()(size_t i) const
{
#ifdef G4DEBUG
if(i>=rwsize)
G4RWTHROW(G4RWBoundsErr("G4RWTValVector operator()",rwsize,i));
#endif
return std_vector::operator[](i);
}
template<class T>
T& G4RWTValVector<T>::operator[](size_t i)
{
if(i>=rwsize)
G4RWTHROW(G4RWBoundsErr("G4RWTValVector operator[]",rwsize,i));
return std_vector::operator[](i);
}
template<class T>
const T& G4RWTValVector<T>::operator[](size_t i) const
{
if(i>=rwsize)
G4RWTHROW(G4RWBoundsErr("G4RWTValVector const operator[]",rwsize,i));
return std_vector::operator[](i);
}
template<class T>
const T* G4RWTValVector<T>::data() const
{
return &(std_vector::front());
}
template<class T>
void G4RWTValVector<T>::resize(size_t N)
{
if(N>std_vector::size())
{
size_t e=N-std_vector::size();
for(size_t i=0;i<e;i++)
std_vector::push_back(T());
}
else
{
iterator it=std_vector::begin();
for(size_t i=1;i<=N;i++,it++);
std_vector::erase(it,std_vector::end());
}
rwsize=N;
}
template<class T>
void G4RWTValVector<T>::reshape(size_t n)
{
resize(n);
}
template<class T>
const T& G4RWTValVector<T>::ref(size_t i) const
{
return std_vector::operator[](i);
}