Ejemplo n.º 1
0
/******************************************************************************
Function Specifications: replaceBeforeCursor
===============================================================================
Preconditions:
  - list is not empty
  - cursor not at beginning of list
Postconditions:
  - the data in the node before the cursor is replaced with newDataItem
  - returns true if successful
Algorithm: 
  - data is changed using cursor movements and assignments
Exceptional/Error Conditions:
  - list empty exception handled (returns false)
  - cursor at beginning exception handled (returns false)
*/
bool LinkedList::replaceBeforeCursor
    ( 
	int newDataItem // input: data to replace existing data
    )
{
    // if empty
    if( isEmpty() )
    {
	return false;
    }

    // if at beginning of list
    else if( cursor == head )
    {
	return false;
    }

    // normal operation
    else
    {
	goToPrior();
	replaceAtCursor( newDataItem );
	return true;
    }
}
Ejemplo n.º 2
0
void Cursor::addAtCursor(const QByteArray &data, bool only_latin)
{
    if (m_insert_mode == Replace) {
        replaceAtCursor(data, only_latin);
    } else {
        insertAtCursor(data, only_latin);
    }
}
Ejemplo n.º 3
0
void Cursor::addAtCursor(const QByteArray &data)
{
    if (m_insert_mode == Replace) {
        replaceAtCursor(data);
    } else {
        insertAtCursor(data);
    }
}
Ejemplo n.º 4
0
/******************************************************************************
Function Specifications: replaceAfterCursor
===============================================================================
Preconditions:
  - list is not empty
  - cursor not at end of list
Postconditions:
  - the data in the node after the cursor is replaced with newDataItem
  - true is returned if successful
Algorithm: 
  - cursor movements are used and assignments manipulate data
Exceptional/Error Conditions:
  - list empty exception handled (returns false)
  - cursor at end exception handled (returns false)
*/
bool LinkedList::replaceAfterCursor
    ( 
     int newDataItem // input: data to replace existing data
    )
{
    // if empty
    if( isEmpty() )
    {
	return false;
    }

    // if at end of list
    else if( cursor->next == NULL )
    {
	return false;
    }
    // normal operation
    else
    {
	goToNext();
	replaceAtCursor( newDataItem );
	return true;
    }
}