NAMD
Public Member Functions | List of all members
AGroup Class Reference

#include <FreeEnergyGroup.h>

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.

18  {
19 //------------------------------------------------------------------------
20 // make room for some ints.
21 //------------------------------------------------------------------------
22  m_NumInts = 0;
23  m_pInts = new int[kGroupNumToStart];
24  m_MaxNum = kGroupNumToStart;
25 }
const int kGroupNumToStart
AGroup::~AGroup ( )

Definition at line 28 of file FreeEnergyGroup.C.

28  {
29 //------------------------------------------------------------------------
30 // return borrowed memory to the free store.
31 //------------------------------------------------------------------------
32  delete []m_pInts;
33 }

Member Function Documentation

void AGroup::Add ( int  AnInt)

Definition at line 44 of file FreeEnergyGroup.C.

References kGroupMultiplier.

Referenced by AddAtom(), and AddResidues().

44  {
45 //------------------------------------------------------------------------
46 // add an int to the list. if there's not enough room, make room.
47 //------------------------------------------------------------------------
48  int* pInts;
49 
50  // if there's no room for a new int
51  if (m_NumInts == m_MaxNum) {
52  // create an array with more space
53  m_MaxNum *= kGroupMultiplier;
54  pInts = new int[m_MaxNum];
55  // fast copy from the full array to the new one (memcpy(dest, src, bytes))
56  memcpy(pInts, m_pInts, sizeof(int)*m_NumInts);
57  // return the space used for the full array
58  delete []m_pInts;
59  // point to the bigger array
60  m_pInts = pInts;
61  }
62 
63  // add the int to the int array
64  m_pInts[m_NumInts] = AnInt;
65  m_NumInts++;
66 }
const int kGroupMultiplier
void AGroup::Clear ( )

Definition at line 36 of file FreeEnergyGroup.C.

36  {
37 //------------------------------------------------------------------------
38 // leave memory allocation alone.
39 //------------------------------------------------------------------------
40  m_NumInts = 0;
41 }
int AGroup::GetNumInGroup ( )
inline

Definition at line 32 of file FreeEnergyGroup.h.

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

32 { return(m_NumInts); }
void AGroup::List ( int  NumToList = -1)

Definition at line 97 of file FreeEnergyGroup.C.

97  {
98 //------------------------------------------------------------------------
99 // list NumToList integers in the group to standard out.
100 // if NumToList is negative, list them all.
101 //------------------------------------------------------------------------
102  int i;
103 
104  if (NumToList < 0) {
105  NumToList = m_NumInts;
106  }
107  for (i=0; i<NumToList; i++) {
108 // cout << setw(10) << i << " " << setw(10) << (*this)[i] << std::endl;
109  CkPrintf("%10d %10d\n", i, (*this)[i]);
110  }
111 }
AGroup & AGroup::operator= ( AGroup Group)

Definition at line 80 of file FreeEnergyGroup.C.

80  {
81 //------------------------------------------------------------------------
82 // make this object identical to the passed one.
83 //------------------------------------------------------------------------
84  // if there's not enough room here for Group's array
85  if (m_MaxNum < Group.m_MaxNum) {
86  // free this array and allocate space for the bigger one
87  delete []m_pInts;
88  m_MaxNum = Group.m_MaxNum;
89  m_pInts = new int[m_MaxNum];
90  }
91  // fast copy from the passed array to this one (memcpy(dest, src, bytes))
92  m_NumInts = Group.m_NumInts;
93  memcpy(m_pInts, Group.m_pInts, sizeof(int)*m_NumInts);
94  return(*this);
95 }
int AGroup::operator[] ( int  Index)

Definition at line 69 of file FreeEnergyGroup.C.

References ASSERT.

69  {
70 //------------------------------------------------------------------------
71 // return an int from this group of ints.
72 // note, by returning int, rather than int&, this function only allows
73 // retrieval of an int, not setting an int. to set, use add.
74 //------------------------------------------------------------------------
75  ASSERT((Index>=0) && (Index<m_NumInts));
76  return(m_pInts[Index]);
77 }
int Index
Definition: structures.h:26
#define ASSERT(E)

The documentation for this class was generated from the following files: