This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:fall2015:data:projects:dln0 [2015/10/10 14:34] – [In inc/data.h] wedge | haas:fall2015:data:projects:dln0 [2015/10/25 22:06] (current) – [node library] wedge | ||
---|---|---|---|
Line 38: | Line 38: | ||
#define _NODE_H | #define _NODE_H | ||
- | #include <stdlib.h> | + | ////////////////////////////////////////////////////////////////////// |
+ | // | ||
+ | // Additional useful information in data.h | ||
+ | // | ||
#include " | #include " | ||
- | // node struct | + | ////////////////////////////////////////////////////////////////////// |
+ | // | ||
+ | // node struct | ||
// | // | ||
struct node { | struct node { | ||
- | char value; | + | union info payload; |
- | struct node *after; | + | struct node |
- | struct node *prior; | + | struct node |
}; | }; | ||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
// function prototypes | // function prototypes | ||
// | // | ||
- | code_t | + | code_t mknode(Node **, char); |
- | code_t | + | code_t cpnode(Node |
- | code_t | + | code_t rmnode(Node **); // deallocate node |
#endif | #endif | ||
Line 60: | Line 67: | ||
There is an addition of a " | There is an addition of a " | ||
- | The node info element has been renamed to "value", just to make sure you understand what is going on code-wise. | + | The node info element has been changed as well... instead of a singular |
====In inc/ | ====In inc/ | ||
You'll notice that node.h includes a file called data.h; This header will contain predominantly useful #define statements, typedefs, and support function prototypes to make our lives easier. It will see additional content added with future projects. | You'll notice that node.h includes a file called data.h; This header will contain predominantly useful #define statements, typedefs, and support function prototypes to make our lives easier. It will see additional content added with future projects. | ||
Line 69: | Line 75: | ||
#define _DATA_H | #define _DATA_H | ||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // We make use of NULL, so we need stdlib | ||
+ | // | ||
#include < | #include < | ||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // Set up union for node payload (multipurpose use) | ||
+ | // | ||
+ | union info { | ||
+ | char | ||
+ | struct node *data; | ||
+ | void *other; | ||
+ | }; | ||
+ | |||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // node struct helper defines | ||
+ | // | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // create some peers to NULL for our endeavors: UNDEFINED | ||
+ | // | ||
+ | #if !defined(UNDEFINED) | ||
+ | #define UNDEFINED ((void*)1) | ||
+ | #endif | ||
+ | |||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
// custom types (mostly for shortening typing) | // custom types (mostly for shortening typing) | ||
// | // | ||
Line 78: | Line 116: | ||
typedef | typedef | ||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
// Status codes for the doubly linked node implementation | // Status codes for the doubly linked node implementation | ||
// | // | ||
- | # | + | # |
- | # | + | # |
- | # | + | # |
- | # | + | # |
- | # | + | # |
- | # | + | # |
- | # | + | # |
- | # | + | # |
- | + | ||
- | // Function prototypes | + | |
- | // | + | |
- | void lscodes(code_t); | + | |
#endif | #endif | ||
Line 117: | Line 153: | ||
You'll notice these #defines map to numeric values, and particular ones at that. This is to our supreme advantage: if you understand how numbers work, you should have an easy time of working with these status codes. | You'll notice these #defines map to numeric values, and particular ones at that. This is to our supreme advantage: if you understand how numbers work, you should have an easy time of working with these status codes. | ||
+ | |||
+ | ====In inc/ | ||
+ | Finally we have support.h... this header will contain some information on helper functions utilized in the various unit tests. You really don't need to bother with this... in fact, do not use any of these functions in your implementation. | ||
====node library==== | ====node library==== | ||
In **src/ | In **src/ | ||
Line 137: | Line 176: | ||
====================================================== | ====================================================== | ||
[mknode] Total: | [mknode] Total: | ||
- | [cpnode] Total: | + | [cpnode] Total: |
[rmnode] Total: | [rmnode] Total: | ||
====================================================== | ====================================================== | ||
- | | + | |
====================================================== | ====================================================== | ||
lab46: | lab46: | ||
</ | </ | ||
- | |||
=====Submission===== | =====Submission===== | ||
{{page> | {{page> | ||