/* Filename: LstTable.cpp Programmer: Br. David Carlson Date: October 7, 1997 Modified: August 8, 1998 Modified: July 17, 2000 to use modern headers. This file implements the functions of the LstTableClass found in LstTable.h. */ #include "lsttable.h" /* Given: Nothing (other than the implicit LstTableClass object). Task: To check whether this object is empty. Return: true if it is empty, false otherwise. */ bool LstTableClass::Empty(void) const { return List.Empty(); // Note the use of 2 different Empty functions! } /* Given: Item A data item. Task: To insert Item into the implicit object, a LstTableClass table. Return: true to indicate success (or false to indicate no success, though this isn't really used -- it's just here in case we want to expand the functionality in the future). The implicit object is modified. */ bool LstTableClass::Insert(const ItemType & Item) { List.InsertFront(Item); return true; // assume success! } /* Given: Searchkey A KeyFieldType value to look up. Task: To look for SearchKey in the table given as the implicit object. Return: Item The structure found that contains Searchkey. In the function name, returns true if SearchKey was found, false otherwise. */ bool LstTableClass::Retrieve(KeyFieldType SearchKey, ItemType & Item) { ListNodePtr NodePtr; ItemType Target; Target.KeyField = SearchKey; NodePtr = List.Find(Target); if (NodePtr == NULL) return false; else { NodePtr->GetInfo(Item); return true; } }