/********************************************************************* C201 Computer Programming II Fall 2006 Dana Vrajitoru & The data structure storing linked lists. **********************************************************************/ #ifndef LIST_STR_H #define LIST_STR_H #include using namespace std; struct Node { string word; Node *next; }; typedef Node * Node_ptr; // List traversal function. It prints all the elements of the list. void Output_list(Node_ptr front); // Returns the number of nodes in the list. int Count_nodes(Node_ptr front); // Inserts a new node at the front of the list. The front is a // reference parameter because the new node becomes the front of the // list. void Insert_front(Node_ptr &front, string s); // Removes the front node of the list. If the list is empty, it // returns false. bool Remove_front(Node_ptr &front); // Deletes the entire list. It must also make the pointer front NULL. void Delete_list(Node_ptr &front); // Returns a pointer to the last node in the list. Node_ptr Last_node(Node_ptr front); // Searches for a particular string in the list. If the string is // there, it returns a pointer to the node that contains it. If not, // it return NULL. Node_ptr Search(Node_ptr front, string s); //****************** Homework functions ****************** // Insert the string as a new node at the back of the list. void Insert_back(Node_ptr &front, string s); // Returns a string obtained by the concatenation of the words in all // the nodes of the list in order and separated by spaces. string Concatenate(Node_ptr front); // Returns a pointer to the node number i in the list, where the first // node is at position 0. If the list has less than i+1 nodes, it // returns NULL. Node_ptr Access_index(Node_ptr front, int i); // Converts the first letter of every word in the list to uppercase. void Toupper_all(Node_ptr front); // Converts the first letter of every word in the list to lowercase. void Tolower_all(Node_ptr front); // Reverses the list. It will most likely create a new list containing // the same nodes as the list starting from front but in reverse // order, then delete the old list and store the address of the first // element of the new list in the pointer front. void Reverse_list(Node_ptr &front); #endif