void DataColumn::removeAll() { // Removes all the rows within the DataColumn if ( m_firstRow == NULL ) { return; } DataRow* rowToDelete; DataRow* currentRow = m_firstRow; while ( currentRow->getNext() != NULL ) { rowToDelete = currentRow; currentRow = currentRow->getNext(); rowToDelete->setPrev(NULL); rowToDelete->setNext(NULL); rowToDelete->setText(""); delete rowToDelete; } m_firstRow = NULL; m_lastRow = NULL; m_currentRow = NULL; }
void DataColumn::removeRow() { // Removes the current DataRow from the DataColumn and the // currentRow pointer will be set to the DataRow after the DataRow you are deleting if ( m_firstRow == NULL ) { return; } DataRow* row; // deals with the case if you only have one row in your DataColumn list if ( m_firstRow == m_lastRow ) { row = m_firstRow; row->setNext(NULL); row->setPrev(NULL); row->setText(""); delete row; m_firstRow = NULL; m_lastRow = NULL; m_currentRow = NULL; return; } // deals with if the row up for deletion is the first row or the last row in the DataColumn list if ( m_currentRow == m_firstRow ) { row = m_firstRow; m_firstRow = m_firstRow->getNext(); row->setNext(NULL); row->setPrev(NULL); row->setText(""); m_firstRow->setPrev(NULL); m_currentRow = m_firstRow; return; } else if ( m_currentRow == m_lastRow ) { row = m_lastRow; m_lastRow = m_lastRow->getPrev(); m_lastRow->setNext(NULL); row->setNext(NULL); row->setPrev(NULL); row->setText(""); m_currentRow = m_lastRow; delete row; return; } // deals with a random DataRow in the DataColumn up for deletion row = m_currentRow; m_currentRow->getPrev()->setNext(m_currentRow->getNext()); m_currentRow->getNext()->setPrev(m_currentRow->getPrev()); row->setPrev(NULL); row->setNext(NULL); row->setText(""); m_currentRow = m_currentRow->getNext(); delete row; }