AGroup Class Reference

#include <FreeEnergyGroup.h>

List of all members.

Public Member Functions

 AGroup ()
 ~AGroup ()
void Clear ()
void Add (int AnInt)
AGroupoperator= (AGroup &Group)
int operator[] (int Index)
int GetNumInGroup ()
void List (int NumToList=-1)


Detailed Description

Definition at line 18 of file FreeEnergyGroup.h.


Constructor & Destructor Documentation

AGroup::AGroup (  ) 

Definition at line 18 of file FreeEnergyGroup.C.

References kGroupNumToStart.

00018                {
00019 //------------------------------------------------------------------------
00020 // make room for some ints.
00021 //------------------------------------------------------------------------
00022   m_NumInts = 0;
00023   m_pInts = new int[kGroupNumToStart];
00024   m_MaxNum = kGroupNumToStart;
00025 }

AGroup::~AGroup (  ) 

Definition at line 28 of file FreeEnergyGroup.C.

00028                 {
00029 //------------------------------------------------------------------------
00030 // return borrowed memory to the free store.
00031 //------------------------------------------------------------------------
00032   delete []m_pInts;
00033 }


Member Function Documentation

void AGroup::Add ( int  AnInt  ) 

Definition at line 44 of file FreeEnergyGroup.C.

References kGroupMultiplier.

Referenced by AddAtom(), and AddResidues().

00044                           {
00045 //------------------------------------------------------------------------
00046 // add an int to the list.  if there's not enough room, make room.
00047 //------------------------------------------------------------------------
00048   int*  pInts;
00049 
00050   // if there's no room for a new int
00051   if (m_NumInts == m_MaxNum) {
00052     // create an array with more space
00053     m_MaxNum *= kGroupMultiplier;
00054     pInts = new int[m_MaxNum];
00055     // fast copy from the full array to the new one (memcpy(dest, src, bytes))
00056     memcpy(pInts, m_pInts, sizeof(int)*m_NumInts);
00057     // return the space used for the full array
00058     delete []m_pInts;
00059     // point to the bigger array
00060     m_pInts = pInts;
00061   }
00062 
00063   // add the int to the int array
00064   m_pInts[m_NumInts] = AnInt;
00065   m_NumInts++;
00066 }

void AGroup::Clear (  ) 

Definition at line 36 of file FreeEnergyGroup.C.

00036                    {
00037 //------------------------------------------------------------------------
00038 // leave memory allocation alone.
00039 //------------------------------------------------------------------------
00040   m_NumInts = 0;
00041 }

int AGroup::GetNumInGroup (  )  [inline]

Definition at line 32 of file FreeEnergyGroup.h.

Referenced by ARestraint::DistributeForce(), and ARestraint::UpdateCOMs().

00032 { return(m_NumInts); }

void AGroup::List ( int  NumToList = -1  ) 

Definition at line 97 of file FreeEnergyGroup.C.

00097                                {
00098 //------------------------------------------------------------------------
00099 // list NumToList integers in the group to standard out.
00100 // if NumToList is negative, list them all.
00101 //------------------------------------------------------------------------
00102   int  i;
00103 
00104   if (NumToList < 0) {
00105     NumToList = m_NumInts;
00106   }
00107   for (i=0; i<NumToList; i++) {
00108 //    cout << setw(10) << i << "   " << setw(10) << (*this)[i] << std::endl;
00109     CkPrintf("%10d   %10d\n", i, (*this)[i]);
00110   }
00111 }

AGroup & AGroup::operator= ( AGroup Group  ) 

Definition at line 80 of file FreeEnergyGroup.C.

References m_MaxNum, m_NumInts, and m_pInts.

00080                                         {
00081 //------------------------------------------------------------------------
00082 // make this object identical to the passed one.
00083 //------------------------------------------------------------------------
00084   // if there's not enough room here for Group's array
00085   if (m_MaxNum < Group.m_MaxNum) {
00086     // free this array and allocate space for the bigger one
00087     delete []m_pInts;
00088     m_MaxNum =  Group.m_MaxNum;
00089     m_pInts = new int[m_MaxNum];
00090   }
00091   // fast copy from the passed array to this one (memcpy(dest, src, bytes))
00092   m_NumInts = Group.m_NumInts;
00093   memcpy(m_pInts, Group.m_pInts, sizeof(int)*m_NumInts);
00094   return(*this);
00095 }

int AGroup::operator[] ( int  Index  ) 

Definition at line 69 of file FreeEnergyGroup.C.

References ASSERT.

00069                                  {
00070 //------------------------------------------------------------------------
00071 // return an int from this group of ints.
00072 // note, by returning int, rather than int&, this function only allows
00073 // retrieval of an int, not setting an int.  to set, use add.
00074 //------------------------------------------------------------------------
00075   ASSERT((Index>=0) && (Index<m_NumInts));
00076   return(m_pInts[Index]);
00077 }


The documentation for this class was generated from the following files:
Generated on Mon Sep 25 01:17:16 2017 for NAMD by  doxygen 1.4.7