This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:summer2015:data:projects:dll0 [2015/06/21 14:36] – [In inc/node.h] wedge | haas:summer2015:data:projects:dll0 [2015/06/27 20:30] (current) – [list library] wedge | ||
---|---|---|---|
Line 37: | Line 37: | ||
#define _LIST_H | #define _LIST_H | ||
- | #include " | + | #include " |
- | + | ||
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
struct list { | struct list { | ||
- | Node *first; | + | Node *first; |
- | Node *last; | + | Node *last; |
}; | }; | ||
- | typedef struct list List; // because we deserve nice things | ||
- | int mklist (List **); | + | code_t |
- | int cplist (List *, List **); // duplicate list contents | + | code_t |
- | int insert (List **, Node *, Node *); | + | code_t |
- | int append (List **, Node *, Node *); | + | code_t |
- | int display(List *, int); // display list from start to end | + | code_t |
- | int find (List *, int, Node **); // locate node containing | + | code_t |
#endif | #endif | ||
</ | </ | ||
- | The following changes have taken place: | + | The following changes have taken place from the singly-linked list implementation: |
* **qty** has been removed from the list | * **qty** has been removed from the list | ||
Line 72: | Line 63: | ||
* **displayf()/ | * **displayf()/ | ||
- | There is now a set of status/ | + | Just as with the doubly-linked node, there are now a set of status/ |
+ | ====In inc/ | ||
+ | In addition to what was there previously, we see the following: | ||
+ | |||
+ | <code c 1> | ||
+ | // Status codes for the doubly linked list implementation | ||
+ | // | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | Similar in many ways to the doubly-linked node status codes, we see a new possibility: | ||
====list operation status codes==== | ====list operation status codes==== | ||
You'll notice the presence of a set of # | You'll notice the presence of a set of # | ||
Line 85: | Line 93: | ||
* **DLL_EMPTY** - result is an empty list (may or may not be 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_DEFAULT_FAIL** - default state of unimplemented functions (default error) | ||
- | * **DLL_FAIL** - some error occurred | + | * **DLL_ERROR** - some error occurred |
+ | * **DLL_INVALID** - invalid use (passing a NULL pointer) | ||
For example, in the case of " | For example, in the case of " | ||
- | * DLL_FAIL | + | * DLL_ERROR |
* DLL_MALLOC_FAIL (a problem has occurred when using malloc()) | * DLL_MALLOC_FAIL (a problem has occurred when using malloc()) | ||
* DLL_NULL (no memory allocated, so list cannot be anything but NULL) | * DLL_NULL (no memory allocated, so list cannot be anything but NULL) | ||
Line 133: | Line 142: | ||
To assist you in verifying a correct implementation, | To assist you in verifying a correct implementation, | ||
- | ====node library==== | ||
- | Here is what you should get for node: | ||
- | |||
- | <cli> | ||
- | lab46: | ||
- | ==================================================== | ||
- | = Verifying Doubly-Linked Node Functionality | ||
- | ==================================================== | ||
- | [mknode] Total: | ||
- | [cpnode] Total: | ||
- | [rmnode] Total: | ||
- | ==================================================== | ||
- | | ||
- | ==================================================== | ||
- | lab46: | ||
- | </ | ||
====list library==== | ====list library==== | ||
Line 158: | Line 151: | ||
= Verifying Doubly-Linked List Functionality | = Verifying Doubly-Linked List Functionality | ||
==================================================== | ==================================================== | ||
- | [mklist] Total: | + | [mklist] Total: |
- | [cplist] Total: | + | [cplist] Total: |
- | [append] Total: | + | [append] Total: |
- | [insert] Total: | + | [insert] Total: |
| | ||
[find] Total: | [find] Total: | ||
==================================================== | ==================================================== | ||
- | | + | |
==================================================== | ==================================================== | ||
lab46: | lab46: |