Singly Linked List
copy over all the files provided for you
the files are in the usual place
copy over you SLinkedList.h and main from the previous lab
For this assignment you will add more functionality to your Singly Linked List
Run the Example Program to see the Singly Linked List in action
THERE IS A TON of logging in the example to explain exactly what is going on
for tonight's lab you Will complete the
public Destructor,
public InsertAfter(T val, T prev_val)
private SListNode * Search(T val)
Search will return a pointer to a SListNode
SlistNode * Search(T val);
use a while loop to search till you find a node where the data in the node matches what you are searching for
, if you reach the end and didnt find it return nullptr;
( you will use the search function inside your InserAfter)
there are 2 step through demonstrations
Insert After
in this walk through I use a while loop to iterate through to find the node I want to insert after, you you can use your search function instead and to directly to the node you want to insert after.
make sure to test InsertAfter by trying to inster after a value that is not in the list.. it should not cause a segmentation fault or break your lists integrity
Destructor
clean up all the nodes,so there are no memory leaks
Your function MUST log the values stored in the nodes as they are deleted..MATCH THE LOG OF THE EXAMPLE
There is a video As well Video
YOUR ToString MUST WORK WITH THE WEBPAGE
viewlist
test files have been provided for you make sure you program output matches the examples
when you redirect in ALL of your testfiles.... MAKE SURE you have one for each datatype
After you add your destructor to clean up the nodes you should not have a memory leak
you can see this when you run
valgrind --leak-check=full ./runme_int < YourIntTestfile
==7604== LEAK SUMMARY:
==7604== definitely lost: 0 bytes in 0 blocks
==7604== indirectly lost: 0 bytes in 0 blocks
==7604== possibly lost: 0 bytes in 0 blocks
BEFORE ASKING FOR GRADING
make sure your output matches that of the runable examples when redirecting in your testfiles
make sure you have testfiles for all the types
make sure that your program does not have a memory leak
make sure you have logging like the example