/***********************************************************************/ /* String List Interface */ /***********************************************************************/ /* A minimal implementation of linked lists. */ /* Author: Mark A. Sheldon, Tufts University, Fall 2012 */ /* */ /* An StringList is either: */ /* - An empty list (the empty list) OR */ /* - A non-empty list node containing: */ /* o a string-valued first element AND */ /* o a StringList for the rest of the elements */ /* */ /* Operations: */ /* (see prototypes below for parameter/type information) */ /* empty() : returns an empty list */ /* isEmpty() : returns true if the given list is empty, */ /* and false otherwise */ /* prepend() : returns a newly allocated list node with the */ /* given data value as the first element and the */ /* given list as the rest */ /* first() : returns the first data value in the given */ /* non-empty list node. */ /* It is an error to pass first() an empty list. */ /* rest() : returns the IntList containing all the elements */ /* except the first one in the given non-empty */ /* list. */ /* It is an error to call rest() on an empty list. */ /* deleteFirst() : returns the IntList that rest() would. */ /* Frees storage associated with the first node . */ /* It is an error to call deleteFirst() on an */ /* empty list. */ /***********************************************************************/ #ifndef __STRINGLIST_H__ #define __STRINGLIST_H__ #include using std::string; struct StringListNode; StringListNode *empty (void); bool isEmpty (StringListNode *list); StringListNode *prepend (string new_data, StringListNode *list); string first (StringListNode *list); StringListNode *rest (StringListNode *list); StringListNode *deleteFirst(StringListNode *list); void deleteAfter(StringListNode *list); #endif