next up previous contents
Next: Find If a Power Up: The Implementation: Previous: Find the Degree of

Deleting a Term:

    // *************************************** //
    // delete a term from the polynomial       //
    // *************************************** //
void FLOAT_POLY::delete_power(unsigned int p)
{
    FLOAT_POLY_CELL *previous,*current,*after;
    previous = get_before_element_address(p);
    current = get_element_address(p); 
    if(current==NULL){
      //cout << "power " << p << " not in the polynomial;"
      //     << " can't delete." << endl; 
      return;
      }
    else{
      if(current==head){
        //here previous = NULL
        previous = head;
        after = head->next;
        head = after;
	previous->next = NULL;
        delete previous;      
        }
      else{
        //sought cell is not at head of list
        after = current->next;
        previous->next = after;
	current->next = NULL;
        delete current;
        }
      }
}



Jim Peterson
1999-04-22