User Tools

Site Tools


notes:fall2024:projects:msi2

This is an old revision of the document!


msi2

mknode() function

Node *mknode (parameters);

To make a node you need to allocate memory for it, and initialize any values that need to be, for parameters you want to pass it anything that might change between nodes, like X and Y coordinates, but anything that remains the same, like speed, can be hard-coded into the function.

rmnode() function

Node *rmnode (Node *);

To be to use rmnode you must first use obtain. rmnode does what it sounds like it does, removes the given node. First you will want to check if the given node is NULL or not as there is no reason to remove something that doesn't exists. Now your given node has an attribute to it (→ next) which will need to be set to NULL, if not then some whacky stuff will happen. Then the node needs to set free like Mufasa from that cliff, cast into the endless void of NULL Wildebeests. And then just like Mufasa the node itself has to become NULL as well. And don't forget that since this is not a void function it needs to return a value!

mklist() function

List *mklist ();

insert() function

List *insert (List *, Node *, Node *);

Your insert function will work similarly to vim, that is it will insert before another node. You will need to pass the function the list you are adding the node to, the node you are inserting before, and the node you are inserting. With a singly linked list inserting is more complicated because you need to find the node preceding the location node without having a direct previous pointer

append() function

List *append (List *, Node *, Node *);

Your append function will work similarly to vim, that is it will append after another node, not necessarily at the end of the list. You will need to pass the function the list you are adding the node to, the node you are appending to, and the node you are appending. Make sure you rework the next pointers, as to not lose any nodes that were already following the location node, ie change newnode → next to be location → next before changing the location's next to be the new node

obtain() function

List *obtain (List *, Node **);

clearlist() function

List *clearlist (List *);

rmlist() function

List *rmlist (List *);
notes/fall2024/projects/msi2.1726881073.txt.gz · Last modified: 2024/09/21 01:11 by cmazzara