This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
haas:spring2015:data:projects:dll0 [2014/11/06 11:46] – external edit 127.0.0.1 | 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 1__: someone jumped the gun and upgraded to dll0 before being fully up-to-date on sll2; this revision effectively does the same initializing actions as that latest sll2 update does (and if you've already applied it, no problem). | + | * __revision 1__: looks like I forgot |
- | * Additionally, | + | * there was a mild typo in the **inc/ |
- | * __revision 2__: various unit-test fixes (20141028) | + | * the parameter to mknode() was incorrectly an int, it should be a char |
- | * unit-append and unit-insert had some syntax errors | + | * updated |
- | * __revision 3__: various unit-test fixes (20141028) | + | * updated |
- | * logic error in unit-display constructs the list incorrectly (FIXED) | + | * __revision |
- | * I may have done something to unit-sortlist; updating that just because. | + | * unit-display had a typo (FIXED) |
- | * __revision | + | * unit-insert is now ready to go |
- | * verify-list.sh updated to support obtain | + | * unit-append should also be good to go |
- | * __revision 5__: unit-findnode and verify-findnode.sh now ready (20141029) | + | * quieted compiler warnings for unit-cplist |
- | * verify-list.sh updated | + | * __revision |
- | * at this point, all list library | + | * unit-find is now operational and conformant to error condition status checking |
- | * node library unit tests still to go, be on the lookout for future updates | + | * there was a bug with checking for a DLL_SUCCESS result, this resulted in fixes to: |
- | * __revision 6__: node library unit tests and verify scripts now ready (20141029) | + | * unit-display |
- | * unit-mknode, unit-cpnode, | + | * unit-insert |
- | * verify-mknode.sh, | + | * unit-append |
- | * at this point, all dll0 project content is released. Future updates should reflect just typos and bug fixes (of which I'm sure there are some). | + | * I've disabled |
- | * __revision | + | * new options in base Makefile: |
- | * unit-obtain had a typo preventing compilation, | + | * "reupdate", which re-applies last revision |
- | * unit-cpnode had a few typos, also now FIXED | + | * " |
- | * there were also 3 logic errors, doing invalid comparisons, | + | * various backend |
- | * I hope that NOW the dll0 code base (as provided) will cleanly compile, and is now feature complete (all intended | + | * __revision 4__: unit-cplist is now fully operational |
- | | + | * also did some house cleaning in list unit Makefile |
- | * __revision 8__: chasing down some logic errors discovered... (20141030) | + | |
- | | + | |
- | * unit-sortlist was calling sortlist() with the incorrect mode under the " | + | |
- | * unit-cplist, | + | |
- | * __revision 9__: in what has been a record number of revisions for a project, | + | |
- | * unit-cplist, | + | |
- | * unit-obtain had an errant append() call which would throw off all the results after a certain point. This is now FIXED. | + | |
- | * all the verify scripts have received some tweaks to improve output flexibility and reduce false negatives, especially on those initial | + | |
- | * verify-list.sh had a bug where it didn't detect successful results correctly. FIXED. | + | |
- | * __revision 10__: as I make further optimizations to the next project (**dls0**), I took the opportunity | + | |
- | * base Makefile: | + | |
- | * verify-node.sh: improved display, more accurate totals | + | |
- | * unit-cpnode.c: improved display | + | |
- | * verify-list.sh: improved display, more accurate totals | + | |
=====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 64: | Line 62: | ||
struct node { | struct node { | ||
- | char data; | + | char value; |
- | struct node *prev; | + | struct node *after; |
- | struct node *next; | + | struct node *prior; |
}; | }; | ||
typedef struct node Node; | typedef struct node Node; | ||
Node *mknode(char | Node *mknode(char | ||
- | Node *rmnode(Node *); // deallocate node | ||
Node *cpnode(Node *); // duplicate node | Node *cpnode(Node *); // duplicate node | ||
+ | Node *rmnode(Node *); // deallocate node | ||
#endif | #endif | ||
</ | </ | ||
- | There is an addition of a "prev" node pointer, to allow connections to our previous neighbors. | + | There is an addition of a "prior" node pointer, to allow connections to our previous neighbors. |
- | The node value element has been renamed to "data", just to make sure you understand what is going on code-wise. | + | The node info element has been renamed to "value", just to make sure you understand what is going on code-wise. |
====In inc/ | ====In inc/ | ||
Line 88: | 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 115: | 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 127: | 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 184: | 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: |