This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:spring2015:data:projects:dll0 [2015/03/23 15:29] – [In inc/node.h] wedge | haas:spring2015:data:projects:dll0 [2015/04/04 22:59] (current) – [Errata] wedge | ||
---|---|---|---|
Line 11: | Line 11: | ||
This section will document any updates applied to the project since original release: | This section will document any updates applied to the project since original release: | ||
- | * __revision | + | * __revision |
+ | * there was a mild typo in the **inc/ | ||
+ | * the parameter to mknode() was incorrectly an int, it should be a char | ||
+ | * updated unit-mklist to check for proper list return status codes | ||
+ | * updated unit-display to check for proper list return status codes | ||
+ | * __revision 2__: updated unit tests to support error condition status (20150402) | ||
+ | * unit-display had a typo (FIXED) | ||
+ | * unit-insert is now ready to go | ||
+ | * unit-append should also be good to go | ||
+ | * quieted compiler warnings for unit-cplist and unit-find (still need to finish) | ||
+ | * __revision 3__: updated more unit tests to support error condition status (20150403) | ||
+ | * unit-find is now operational and conformant to error condition status checking | ||
+ | * there was a bug with checking for a DLL_SUCCESS result, this resulted in fixes to: | ||
+ | * unit-display | ||
+ | * unit-insert | ||
+ | * unit-append | ||
+ | * I've disabled the cplist unit test and verify-list does not try to run it (so you won't be impeded by its current unfinished state) | ||
+ | * new options in base Makefile: | ||
+ | * " | ||
+ | * " | ||
+ | * various backend infrastructure tweaks (because I deserve nice things) | ||
+ | * __revision 4__: unit-cplist is now fully operational (20150404) | ||
+ | * also did some house cleaning in list unit Makefile | ||
=====Objective===== | =====Objective===== | ||
In this project, we take our first opportunity to undergo a complete code re-write of linked list functionality, | In this project, we take our first opportunity to undergo a complete code re-write of linked list functionality, | ||
+ | =====Procedure to Obtain dll0===== | ||
+ | As this is a rewrite, dll0 is not based on any of the code you have written up to this point. As such, the transition process is slightly different: | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | The " | ||
+ | |||
+ | But when you " | ||
+ | |||
+ | Once you run " | ||
=====Project Overview===== | =====Project Overview===== | ||
Line 33: | Line 68: | ||
typedef struct node Node; | typedef struct node Node; | ||
- | Node *mknode(int ); // allocate new node containing value | + | Node *mknode(char |
Node *cpnode(Node *); // duplicate node | Node *cpnode(Node *); // duplicate node | ||
Node *rmnode(Node *); // deallocate node | Node *rmnode(Node *); // deallocate node | ||
Line 51: | Line 86: | ||
#include " | #include " | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
struct list { | struct list { | ||
- | Node *start; // pointer to start of list | + | Node *first; |
- | Node *end; // pointer to end of list | + | Node *last; // pointer to end of list |
}; | }; | ||
- | typedef struct list List; | + | typedef struct list List; // because we deserve nice things |
- | List *mklist(void | + | int mklist (List **); // create/ |
- | List *cplist(List *); // copy (duplicate) list | + | int cplist (List *, |
- | List *rmlist(List | + | |
- | List *insert (List *, Node *, Node *); // add node before given node | + | int insert (List **, Node *, Node *); |
- | List *append (List *, Node *, Node *); // add node after given node | + | int append (List **, Node *, Node *); |
- | List *obtain (List *, Node ** | + | |
- | void | + | int display(List *, int); // display list from start to end |
- | + | int find (List *, int, Node **); // locate node containing value | |
- | Node *findnode(List *, int); // locate node containing value | + | |
- | List *sortlist(List *, int); // sort list (according to mode) | + | |
- | + | ||
- | List *swapnode(List *, Node *, Node *); // swap positions of given nodes in list | + | |
#endif | #endif | ||
Line 78: | Line 115: | ||
The following changes have taken place: | The following changes have taken place: | ||
- | * **qty** has been removed from the list; any code you wrote that is based on it will need to be implemented a different way (do NOT recreate the conditions to continue relying on a count, you will lose credit if you do so). | + | * **qty** has been removed from the list |
* **getpos()**/ | * **getpos()**/ | ||
- | * **searchlist()** has been renamed to **findnode()** (aesthetic change, to keep function names at 8 characters or less). | + | * **searchlist()** has been renamed to **find()** (aesthetic change, to keep function names at 8 characters or less, and now supports resuming (finding additional matches). |
* **displayf()/ | * **displayf()/ | ||
+ | There is now a set of status/ | ||
+ | |||
+ | ====list operation status codes==== | ||
+ | You'll notice the presence of a set of # | ||
+ | |||
+ | They are not exclusive- in some cases, multiple states can be applied. The intent is that you will OR together all pertinent states and return that from the function. | ||
+ | |||
+ | * **DLL_SUCCESS** - everything went according to plan, no errors encountered, | ||
+ | * **DLL_MALLOC_FAIL** - memory allocation failed (considered in error) | ||
+ | * **DLL_ALREADY_ALLOC** - memory has already been allocated (considered in error) | ||
+ | * **DLL_NULL** - result is NULL (probably in error) | ||
+ | * **DLL_EMPTY** - result is an empty list (may or may not be in error) | ||
+ | * **DLL_DEFAULT_FAIL** - default state of unimplemented functions (default error) | ||
+ | * **DLL_FAIL** - some error occurred | ||
+ | |||
+ | For example, in the case of " | ||
+ | * DLL_FAIL (a problem has occurred) | ||
+ | * DLL_MALLOC_FAIL (a problem has occurred when using malloc()) | ||
+ | * DLL_NULL (no memory allocated, so list cannot be anything but NULL) | ||
+ | |||
+ | ALL THREE states must be returned from the function in question should such an occurrence take place. | ||
====list library==== | ====list library==== | ||
In **src/ | In **src/ | ||
Line 90: | Line 148: | ||
Figure out what is going on, the connections, | Figure out what is going on, the connections, | ||
- | As ALL source files are now skeletons, no sample code has been given. This is intended | + | Be sure to focus on implementing the functionality from scratch (the more you do this from scratch, vs. referencing old code, the more it will help you). |
====List library unit tests==== | ====List library unit tests==== | ||
In **testing/ | In **testing/ | ||
+ | * **unit-mklist.c** - unit test for **mklist()** library function | ||
+ | * **unit-cplist.c** - unit test for **cplist()** library function | ||
* **unit-append.c** - unit test for **append()** library function | * **unit-append.c** - unit test for **append()** library function | ||
* **unit-insert.c** - unit test for **insert()** library function | * **unit-insert.c** - unit test for **insert()** library function | ||
- | * **unit-swapnode.c** - unit test for **swapnode()** library function | + | * **unit-find.c** - unit test for **find()** library function |
- | * **unit-sortlist.c** - unit test for **sortlist()** library function | + | |
* **unit-display.c** - unit test for **display()** library function | * **unit-display.c** - unit test for **display()** library function | ||
- | Additional | + | Enhancements to these unit tests may be provided via dll0 project updates. |
There are also corresponding **verify-FUNCTION.sh** scripts that will output a " | There are also corresponding **verify-FUNCTION.sh** scripts that will output a " | ||
Line 147: | Line 206: | ||
= Verifying Doubly-Linked List Functionality | = Verifying Doubly-Linked List Functionality | ||
==================================================== | ==================================================== | ||
- | [mklist] Total: | + | [mklist] Total: |
- | [cplist] Total: | + | [cplist] Total: |
- | [rmlist] Total: | + | [append] Total: |
- | [append] Total: | + | [insert] Total: |
- | [insert] Total: | + | [display] Total: |
- | [obtain] Total: | + | [find] Total: |
- | [display] Total: | + | |
- | [findnode] Total: | + | |
- | [sortlist] Total: | + | |
- | [swapnode] Total: | + | |
==================================================== | ==================================================== | ||
- | | + | |
==================================================== | ==================================================== | ||
lab46: | lab46: |