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
Search will return a pointer to a SListNode
SlistNode * Search(T val);
use a while loop to search from the head to the end.
if you find a node where the data in the node matches what you are searching for return pointer to that node
if you reach the end and didnt find it return nullptr
this would be a good example of a function that you would problaby want to make private but we will leave it public here
so that we can call it from the menu driven main.
Insert After
Instead of alsways inserting at the head this function will have two parameters , the value to insert and the value after which it should be inserted
Use the Search function to find the proper node to insert after.
When testing be sure to add one after the first value, add one after the last value, add one to the middle value wiht at least 3 values already in the list.
make sure to test by trying to insert after a value that is not in the list.. it should not cause a segmentation fault or break your lists integrity
it should simply fail to do the operation and return false
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
NOTE: if your ToString works properly after the first lab there is no reason why you should need to change it.
If you are experiencing segmentation faults after calling the InsertAfter it is becuase there is a problem with
the InsertAter function not the ToString.
If you can add 4-5 values using ONLY the Insert function and the ToString works then your ToSTring is fine.
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