User Tools

Site Tools


notes:fall2024:projects:msi3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:fall2024:projects:msi3 [2024/10/03 00:31] – [mknode() function] cburlingnotes:fall2024:projects:msi3 [2024/10/03 01:38] (current) – [clearlist() function] jmerri10
Line 9: Line 9:
 The primary difference between a singly and doubly-linked list is that a singly-linked list can only move forward in direction. For example, if you start at First, you can only move to the next until you hit the Last. With a doubly-linked list, you can move both to the next and previous node, offering more freedom in data access. However, keep in mind this will require more hygiene of the user to keep the pointers between nodes in order, both for making the nodes and removing them. The primary difference between a singly and doubly-linked list is that a singly-linked list can only move forward in direction. For example, if you start at First, you can only move to the next until you hit the Last. With a doubly-linked list, you can move both to the next and previous node, offering more freedom in data access. However, keep in mind this will require more hygiene of the user to keep the pointers between nodes in order, both for making the nodes and removing them.
 =====mknode() function===== =====mknode() function=====
-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. And don't forget that this is a non void function, meaning that it needs to **return a value**!+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.\\  
 +Don't forget that this is a non void function, meaning that it needs to **return a value**!
   * There is no real difference between mknode() for a singly or a doubly-linked list   * There is no real difference between mknode() for a singly or a doubly-linked list
  
 =====rmnode() function===== =====rmnode() function=====
 +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) and (→ prev) which will both need to be set to **NULL**, if not then some undesirable stuff will happen. Then the node is prepped to be removed. \\ 
 +Don't forget that since this is not a void function it needs to **return a value**!
  
-=====mklist() function===== 
  
 +=====mklist() function=====
 +For mklist one must name there list like they have the other struct objects in previous projects. And also just like previous projects one must allocate memory for said list! Or else there will be issues in your future! In typical faction one must set their lists attributes to **NULL**.\\ 
 +Don't forget that this is a non void function, meaning that it needs to **return a value**!
 =====insert() function===== =====insert() function=====
 The insert function should operate a bit like the append function. However, this time it should allow a node to be placed wherever in the last as opposed to strictly the end. If desired, insert could be used like obtain(). The insert function should operate a bit like the append function. However, this time it should allow a node to be placed wherever in the last as opposed to strictly the end. If desired, insert could be used like obtain().
Line 33: Line 38:
 Don't forget that since this is a function it needs a return value! Don't forget that since this is a function it needs a return value!
 =====obtain() function===== =====obtain() function=====
 +For the most part, the obtain() function should be the same as the obtain() function in msi2. Loop through your list until you find the node you would like to obtain, then return the list. 
 =====clearlist() function===== =====clearlist() function=====
 +The clearlist() function should be the same as in msi2, as well. Loop through your list and remove each node in the list using your rmnode() function until the list reaches NULL (end of list). Make sure the list's start and end is NULL, then return the list.
 =====rmlist() function===== =====rmlist() function=====
  
 The rmlist function will call clearlist() function. After the list is successfully cleared, then the list itself will be deallocated from memory. The rmlist function will call clearlist() function. After the list is successfully cleared, then the list itself will be deallocated from memory.
notes/fall2024/projects/msi3.1727915466.txt.gz · Last modified: 2024/10/03 00:31 by cburling