// FILE: listpiece.h // PROVIDES: A function to copy a piece of a list composed // of nodes as specified in node1.h, in namespace main_savitch_5. // // Augments linked list toolkit as per Self-Test Exercise 24 on // page 258 of the textbook. Helpful to implement sequence class // using a linked list, as discussed on page 277 of the textbook. // // void list_piece(const node* start_ptr, const node* end_ptr, // node*& head_ptr, node*& tail_ptr) // Precondition: start_ptr and end_ptr are pointers to nodes on the same // linked list, with the start_ptr node at or before the end_ptr node // Postcondition: head_ptr and tail_ptr are the head and tail pointers for a // new list that contains the items from start_ptr up to but not including // end_ptr. The end_ptr may also be NULL, in which case the new list // contains elements from start_ptr to the end of the list. // // DYNAMIC MEMORY usage: // If there is insufficient dynamic memory, list_piece will throw bad_alloc. #ifndef LIST_PIECE_H #define LIST_PIECE_H #include "node1.h" namespace main_savitch_5 { void list_piece(const node* start_ptr, const node* end_ptr, node*& head_ptr, node*& tail_ptr); } #endif