// file: ll_stack_1.cc
//

// isip include files
//
#include "link_list.h"
#include "link_list_constants.h"

// method: pop_cc
//
// arguments: none
//
// return: a Link_node* containing the head of the list
//
// this method removes and returns the node at the head of the linked
// list and connects the list accordingly
//
Link_node* Link_list::pop_cc() {

  // dummy variable
  //
  Link_node* node = head_d;

  // remove the head node and move the links up
  //
  if (head_d != (Link_node*)NULL) {
    head_d = head_d->get_next_cc();
    node->set_next_cc((Link_node*)NULL);
  }

  // check if there are any nodes left
  //
  if (head_d != (Link_node*)NULL) {
    head_d->set_prev_cc((Link_node*)NULL);
  }
  else {
    curr_d = head_d;
  }
  
  // return node and exit gracefully
  //
  return node;
}
