User Tools

Site Tools


notes:data:fall2022:projects:sll0

This is an old revision of the document!


BACKGROUND

As we are slowly building onto our code library, this week we will be moving forward to list manipulating functions, lists containing nodes; at this point, we should now have fully functional node processing functions as the foundation.

If you remember from our pseudocode from sln0, one of the processes we implemented to include new nodes into a list was to insert them. That is what we will be focusing on…

First and foremost, after upgrading your project folder, as explained further down below, you will find a new header file inside the inc directory called 'list.h'. This header declares a new type of struct called List, with two pointer properties lead and last, and five new functions:

  • mklist()
  • setpos()
  • getpos()
  • insert()
  • displays()

It is recommended to work on them in that order. If you choose to work on them in that order, know that the unit tests call on display so you will need to comment out the display call inside the unit tests of setpos, getpos, and insert. However, mklist works fine and should be the first one completed.

You will now have a new directory as well called 'list', /sll0/src/list/.
Here you will find four new .c files containing their corresponding functions:

  • mk.c
  • pos.c
  • insert.c
  • displayf.c

SPECIFICATIONS

Our goal is to implement five functions in four files. The files are located in the /src/list directories along with a makefile. The functions are themed on the use of lists.

To get the project files:

cd /sln1
make upgrade-sll0
cd ../sll0/

* this will upgrade sln1 → sll0

NOTICE: To easily compile your files, from the base directory you can run make clean followed by make default afterwards you can run make check or inside the bin folder run the desired unit test if you want more specific information of what went wrong.

*Our task is to ask questions on Discord or in class and document our findings on this wiki page collaboratively, regarding the functionality of this project.

*For anybody interested in editing the wiki page, here is the dokuwiki user guide: https://www.dokuwiki.org/wiki:syntax#basic_text_formatting -Ash

PROGRAM

mklist() should make a new list containing a lead and last node. These nodes point to the start and end of the list.

getpos() should get the position of the node passed into the function. It should look at the node passed in → info and find that node inside the list. If that node isn't found inside the list it should return the appropriate error specified inside pos.c.

setpos() should set a new Node* to a position specified by a number passed into the function, think of setting a tmp variable and looping to get to that position as done in sln0.

insert() should put a new node containing a value passed into the function before the specified place. This place will be passed into the function as will the new node. For optimization of your program these should utilize the setpos() and getpos() functions to set new nodes to maintain the list. The list should be able to insert before the start and anywhere else. Remember that if the node is one after the start, you will have to set the lead's right to the new node.

OUTPUT SPECIFICATIONS

UNIT TESTS

When running make check there will be 43 total match checks, when the functions are setup correctly, all 43 should match the output of the unit tests.

notes/data/fall2022/projects/sll0.1663433025.txt.gz · Last modified: 2022/09/17 16:43 by hcordell