msm::Array< T > Class Template Reference

#include <MsmMap.h>

List of all members.

Public Member Functions

 Array ()
 Array (int n)
 Array (const Array &a)
 ~Array ()
Arrayoperator= (const Array &a)
int len () const
int max () const
const T & operator[] (int i) const
const T & elem (int i) const
T & operator[] (int i)
T & elem (int i)
void append (const T &t)
void resize (int n)
void setmax (int m)
const T * buffer () const
T * buffer ()
const T * buffer (int &n) const
T * buffer (int &n)
void reset (const T &t)

Protected Member Functions

void copy (const Array &a)

Protected Attributes

T * abuffer
int alen
int amax

Friends

void swap (Array &, Array &)


Detailed Description

template<class T>
class msm::Array< T >

Definition at line 208 of file MsmMap.h.


Constructor & Destructor Documentation

template<class T>
msm::Array< T >::Array ( void   )  [inline]

Definition at line 210 of file MsmMap.h.

00210 : abuffer(0), alen(0), amax(0) { }

template<class T>
msm::Array< T >::Array ( int  n  )  [inline]

Definition at line 211 of file MsmMap.h.

00211 : abuffer(0), alen(0), amax(0) { resize(n); }

template<class T>
msm::Array< T >::Array ( const Array< T > &  a  )  [inline]

Definition at line 212 of file MsmMap.h.

00212 : abuffer(0), alen(0), amax(0) { copy(a); }

template<class T>
msm::Array< T >::~Array ( void   )  [inline]

Definition at line 213 of file MsmMap.h.

00213 { setmax(0); }


Member Function Documentation

template<class T>
void msm::Array< T >::append ( const T &  t  )  [inline]

Definition at line 250 of file MsmMap.h.

Referenced by ComputeMsm::doWork(), and msm::PriorityQueue< T >::insert().

00250                               {
00251         if (alen==amax) setmax(2*amax+1);
00252         abuffer[alen++] = t;
00253       }

template<class T>
T* msm::Array< T >::buffer ( int &  n  )  [inline]

Definition at line 262 of file MsmMap.h.

00262 { n = alen; return abuffer; }

template<class T>
const T* msm::Array< T >::buffer ( int &  n  )  const [inline]

Definition at line 261 of file MsmMap.h.

00261 { n = alen; return abuffer; }

template<class T>
T* msm::Array< T >::buffer (  )  [inline]

Definition at line 260 of file MsmMap.h.

00260 { return abuffer; }

template<class T>
const T* msm::Array< T >::buffer (  )  const [inline]

Definition at line 259 of file MsmMap.h.

Referenced by msm::PatchData::anterpolationC1Hermite(), MsmC1HermiteBlockProxyMsg::get(), MsmBlockProxyMsg::get(), msm::PatchData::interpolationC1Hermite(), MsmGridCutoffMap::MsmGridCutoffMap(), MsmC1HermiteBlockProxyMsg::put(), and MsmBlockProxyMsg::put().

00259 { return abuffer; }

template<class T>
void msm::Array< T >::copy ( const Array< T > &  a  )  [protected]

Referenced by msm::Array< msm::PatchDiagram >::Array(), and msm::Array< msm::PatchDiagram >::operator=().

template<class T>
T& msm::Array< T >::elem ( int  i  )  [inline]

Definition at line 242 of file MsmMap.h.

00242                      {
00243         if (i < 0 || i >= alen) {
00244           char msg[100];
00245           snprintf(msg, sizeof(msg), "Array index:  alen=%d, i=%d\n", alen, i);
00246           NAMD_die(msg);
00247         }
00248         return abuffer[i];
00249       }

template<class T>
const T& msm::Array< T >::elem ( int  i  )  const [inline]

Definition at line 227 of file MsmMap.h.

Referenced by msm::Array< msm::PatchDiagram >::operator[]().

00227                                  {
00228         if (i < 0 || i >= alen) {
00229           char msg[100];
00230           snprintf(msg, sizeof(msg), "Array index:  alen=%d, i=%d\n", alen, i);
00231           NAMD_die(msg);
00232         }
00233         return abuffer[i];
00234       }

template<class T>
int msm::Array< T >::len (  )  const [inline]

Definition at line 218 of file MsmMap.h.

Referenced by msm::PatchData::anterpolation(), msm::PatchData::anterpolationC1Hermite(), ComputeMsmMgr::compute(), ComputeMsm::doWork(), msm::PatchData::interpolation(), msm::PatchData::interpolationC1Hermite(), MsmC1HermiteBlockProxyMsg::put(), MsmBlockProxyMsg::put(), msm::PriorityQueue< T >::remove(), and msm::PatchData::sendChargeC1Hermite().

00218 { return alen; }

template<class T>
int msm::Array< T >::max (  )  const [inline]

Definition at line 219 of file MsmMap.h.

00219 { return amax; }

template<class T>
Array& msm::Array< T >::operator= ( const Array< T > &  a  )  [inline]

Definition at line 214 of file MsmMap.h.

00214                                        {
00215         if (this != &a) copy(a);  // don't allow self-assignment
00216         return(*this);
00217       }

template<class T>
T& msm::Array< T >::operator[] ( int  i  )  [inline]

Definition at line 235 of file MsmMap.h.

00235                            {
00236 #ifdef DEBUG_MSM
00237         return elem(i);
00238 #else
00239         return abuffer[i];
00240 #endif
00241       }

template<class T>
const T& msm::Array< T >::operator[] ( int  i  )  const [inline]

Definition at line 220 of file MsmMap.h.

00220                                        {
00221 #ifdef DEBUG_MSM
00222         return elem(i);
00223 #else
00224         return abuffer[i];
00225 #endif
00226       }

template<class T>
void msm::Array< T >::reset ( const T &  t  )  [inline]

Definition at line 263 of file MsmMap.h.

00263                              {
00264         for (int n = 0;  n < alen;  n++)  abuffer[n] = t;
00265       }

template<class T>
void msm::Array< T >::resize ( int  n  )  [inline]

Definition at line 254 of file MsmMap.h.

Referenced by msm::Array< msm::PatchDiagram >::Array(), msm::PriorityQueue< T >::clear(), ComputeMsm::doWork(), MsmC1HermiteBlockProxyMsg::get(), MsmBlockProxyMsg::get(), msm::PriorityQueue< T >::init(), msm::PatchData::init(), ComputeMsmMgr::initialize_create(), and msm::PriorityQueue< T >::remove().

00254                          {
00255         if (n > amax) setmax(n);
00256         alen = n;
00257       }

template<class T>
void Array< T >::setmax ( int  m  ) 

Definition at line 281 of file MsmMap.h.

References msm::Array< T >::abuffer, msm::Array< T >::alen, msm::Array< T >::amax, and NAMD_die().

Referenced by msm::Array< msm::PatchDiagram >::append(), msm::Array< msm::PatchDiagram >::resize(), and msm::Array< msm::PatchDiagram >::~Array().

00281                              {
00282     if (m == amax) return;
00283     else if (m > 0) {
00284       T *newbuffer = new T[m];
00285       if ( ! newbuffer) {
00286         char msg[100];
00287         snprintf(msg, sizeof(msg),
00288             "Can't allocate %lu KB for msm::Array\n",
00289             (unsigned long)(m * sizeof(T) / 1024));
00290         NAMD_die(msg);
00291       }
00292       if (alen > m) alen = m;  // new buffer is shorter than old buffer
00293       for (int i = 0;  i < alen;  i++) {
00294         newbuffer[i] = abuffer[i];
00295       }
00296       delete[] abuffer;
00297       abuffer = newbuffer;
00298       amax = m;
00299     }
00300     else {  // consider m == 0
00301       delete[] abuffer;
00302       abuffer = 0;
00303       alen = 0;
00304       amax = 0;
00305     }
00306   }


Friends And Related Function Documentation

template<class T>
void swap ( Array< T > &  ,
Array< T > &   
) [friend]


Member Data Documentation

template<class T>
T* msm::Array< T >::abuffer [protected]

Definition at line 275 of file MsmMap.h.

Referenced by msm::Array< msm::PatchDiagram >::append(), msm::Array< msm::PatchDiagram >::buffer(), msm::Array< msm::PatchDiagram >::elem(), msm::Array< msm::PatchDiagram >::operator[](), msm::Array< msm::PatchDiagram >::reset(), msm::Array< T >::setmax(), and msm::swap().

template<class T>
int msm::Array< T >::alen [protected]

Definition at line 276 of file MsmMap.h.

Referenced by msm::Array< msm::PatchDiagram >::append(), msm::Array< msm::PatchDiagram >::buffer(), msm::Array< msm::PatchDiagram >::elem(), msm::Array< msm::PatchDiagram >::len(), msm::Array< msm::PatchDiagram >::reset(), msm::Array< msm::PatchDiagram >::resize(), msm::Array< T >::setmax(), and msm::swap().

template<class T>
int msm::Array< T >::amax [protected]

Definition at line 276 of file MsmMap.h.

Referenced by msm::Array< msm::PatchDiagram >::append(), msm::Array< msm::PatchDiagram >::max(), msm::Array< msm::PatchDiagram >::resize(), msm::Array< T >::setmax(), and msm::swap().


The documentation for this class was generated from the following file:
Generated on Fri Nov 24 01:17:21 2017 for NAMD by  doxygen 1.4.7