User Tools

Site Tools


haas:fall2015:data:projects:dln0

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
haas:fall2015:data:projects:dln0 [2015/10/10 14:34] – [In inc/data.h] wedgehaas: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 "data.h" #include "data.h"
  
-// node struct+////////////////////////////////////////////////////////////////////// 
 +// 
 +// node struct definition
 // //
 struct node { struct node {
-        char         value+    union  info      payload
-        struct node *after; +    struct node     *after; 
-        struct node *prior;+    struct node     *prior;
 }; };
  
 +//////////////////////////////////////////////////////////////////////
 +//
 // function prototypes // function prototypes
 // //
-code_t  mknode(Node **, char  );       // allocate new node containing value +code_t mknode(Node **, char);    // allocate new node containing value 
-code_t  cpnode(Node *,  Node **);      // duplicate node +code_t cpnode(Node  *, Node **); // duplicate node 
-code_t  rmnode(Node **);               // deallocate node+code_t rmnode(Node **);          // deallocate node
  
 #endif #endif
Line 60: Line 67:
 There is an addition of a "prior" 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 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 value, it is now a union by the name of payload, which contains a value entry (a char entry), a data entry (Node pointer), and an other entry (a void pointer).
 ====In inc/data.h==== ====In inc/data.h====
 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 <stdlib.h> #include <stdlib.h>
  
 +//////////////////////////////////////////////////////////////////////
 +//
 +// Set up union for node payload (multipurpose use)
 +//
 +union info {
 +    char         value;
 +    struct node *data;
 +    void        *other;
 +};
 +
 +//////////////////////////////////////////////////////////////////////
 +//
 +// node struct helper defines
 +//
 +#define  VALUE   payload.value
 +#define  DATA    payload.data
 +#define  OTHER   payload.other
 +
 +//////////////////////////////////////////////////////////////////////
 +//
 +// 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   signed long long int slli; typedef   signed long long int slli;
  
 +//////////////////////////////////////////////////////////////////////
 +//
 // Status codes for the doubly linked node implementation // Status codes for the doubly linked node implementation
 // //
-#define  DLN_SUCCESS         0x0100 +#define  DLN_SUCCESS         0x0000000000000100 
-#define  DLN_MALLOC_FAIL     0x0200 +#define  DLN_MALLOC_FAIL     0x0000000000000200 
-#define  DLN_ALREADY_ALLOC   0x0400 +#define  DLN_ALREADY_ALLOC   0x0000000000000400 
-#define  DLN_NULL            0x0800 +#define  DLN_NULL            0x0000000000000800 
-#define  DLN_ERROR           0x1000 +#define  DLN_ERROR           0x0000000000001000 
-#define  DLN_DEFAULT_FAIL    0x2000 +#define  DLN_INVALID         0x0000000000002000 
-#define  DLN_INVALID         0x4000 +#define  DLN_DEFAULT_FAIL    0x0000000000004000 
-#define  DLN_RESERVED_CODE   0x8000 +#define  DLN_RESERVED_CODE   0x0000000000008000
- +
-// 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/support.h====
 +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/node/**, you will find skeletons of what was previously there, ready for you to re-implement. In **src/node/**, you will find skeletons of what was previously there, ready for you to re-implement.
Line 137: Line 176:
 ====================================================== ======================================================
     [mknode] Total:  12, Matches:  12, Mismatches:   0     [mknode] Total:  12, Matches:  12, Mismatches:   0
-    [cpnode] Total:  15, Matches:  15, Mismatches:   0+    [cpnode] Total:  17, Matches:  17, Mismatches:   0
     [rmnode] Total:   4, Matches:   4, Mismatches:   0     [rmnode] Total:   4, Matches:   4, Mismatches:   0
 ====================================================== ======================================================
-   [RESULTS] Total:  31, Matches:  31, Mismatches:   0+   [RESULTS] Total:  33, Matches:  33, Mismatches:   0
 ====================================================== ======================================================
 lab46:~/src/data/dln0$  lab46:~/src/data/dln0$ 
 </cli> </cli>
- 
 =====Submission===== =====Submission=====
 {{page>haas:fall2015:common:submitblurb#DATA&noheader&nofooter}} {{page>haas:fall2015:common:submitblurb#DATA&noheader&nofooter}}
  
haas/fall2015/data/projects/dln0.1444487653.txt.gz · Last modified: 2015/10/10 14:34 by wedge