4 * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.
20 Array2D():m_dimRow(0), m_dimCol(0){;}
21 Array2D(int nRow, int nCol)
25 for (int i=0; i < nRow; i++)
29 m_2DVector.push_back(x);
43 void SetAt(int nRow, int nCol, const T& value)
45 m_2DVector[nRow][nCol] = value;
47 T GetAt(int nRow, int nCol)
49 return m_2DVector[nRow][nCol];
51 void GrowRow(int newSize)
53 if (newSize <= (int)m_dimRow)
56 for(int i = 0 ; i < newSize - (int)m_dimCol; i++)
58 vector<T> x(m_dimRow);
59 m_2DVector.push_back(x);
62 void GrowCol(int newSize)
64 if(newSize <= (int)m_dimCol)
67 for (int i=0; i < (int)m_dimRow; i++)
68 m_2DVector[i].resize(newSize);
71 void ResizeRect(int row, int col)
77 /* This is to get everything initialised to a value */
78 void GrowRow(int newSize, const T& value)
80 if (newSize <= m_dimRow)
83 for(int i = 0 ; i < newSize - m_dimCol; i++)
85 vector<T> x(m_dimRow, value);
86 m_2DVector.push_back(x);
89 void GrowCol(int newSize, const T& value)
91 if(newSize <= m_dimCol)
94 for (int i=0; i <m_dimRow; i++)
95 m_2DVector[i].resize(newSize, value);
98 void ResizeRect(int row, int col, const T& value)
106 for(int row=0; row < m_dimRow; row++)
108 for(int col=0; col < m_dimCol; col++)
110 cout <<" "<< m_2DVector[row][col];
118 int size = m_2DVector.size();
119 for(int i = 0; i < size; i++)
121 m_2DVector[i].clear();
129 vector<T>& operator[](int x)
131 return m_2DVector[x];
134 vector< vector <T> > m_2DVector;
135 unsigned int m_dimRow;
136 unsigned int m_dimCol;