Table of Contents

Corning Community College

CSCS2320 Data Structures

~~TOC~~

Project: DLL0

Errata

This section will document any updates applied to the project since original release:

Objective

In this project, we continue our doubly-linked code re-write, this time focusing on the linked list.

Procedure to obtain dll0

As dll0 utilizes the code generated in dln0, transitioning to this project is merely a matter of upgrading:

lab46:~/src/data/dln0$ make upgrade-dll0
...

When you upgrade, your existing code is copied over, because the next project builds upon what you did previously.

Once you run “make upgrade-dll0” you should have a dll0 directory that you can access and commence working on just as you have with the other project directories.

Project Overview

For this project, we're going to be re-implementing MOST of the previous node and list functions. There have been a few changes, namely:

In inc/list.h

1
#ifndef _LIST_H
#define _LIST_H
 
#include "node.h"                          // list relies on node to work
 
struct list {
    Node              *first;              // pointer to start of list
    Node              *last;               // pointer to end of list
};
 
code_t  mklist (List **);                  // create new list struct
code_t  cplist (List  *, List **);         // duplicate list contents 
 
code_t  insert (List **, Node *, Node  *); // add node before given node
code_t  append (List **, Node *, Node  *); // add node after given node
 
code_t  display(List  *, int);             // display list start to end
code_t  find   (List  *, int,    Node **); // locate node with value
 
#endif

The following changes have taken place from the singly-linked list implementation:

Just as with the doubly-linked node, there are now a set of status/error codes that will be utilized as list function return values, so we can better report particular failures.

In inc/data.h

In addition to what was there previously, we see the following:

1
// Status codes for the doubly linked list implementation
//
#define  DLL_SUCCESS         0x0000000000000100
#define  DLL_MALLOC_FAIL     0x0000000000000200
#define  DLL_ALREADY_ALLOC   0x0000000000000400
#define  DLL_NULL            0x0000000000000800
#define  DLL_ERROR           0x0000000000001000
#define  DLL_DEFAULT_FAIL    0x0000000000002000
#define  DLL_EMPTY           0x0000000000004000
#define  DLL_INVALID         0x0000000000008000

Similar in many ways to the doubly-linked node status codes, we see a new possibility: EMPTY. This is the state of a list existing but having no nodes associated with it (which you should already be familiar with). Whenever this state exists, that status code MUST be set in the respective function being called (so, the list as a result of the function processing leaves us with an empty list).

list operation status codes

You'll notice the presence of a set of #define's in the list header file. These are intended to be used to report on various states of list status after performing various operations.

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.

For example, in the case of “DLL_MALLOC_FAIL”, there are actually a total of three states raised:

ALL THREE states must be returned from the function in question should such an occurrence take place.

list library

In src/node/, you will find skeletons of what was previously there, ready for you to re-implement.

In src/list/, you will find the same- skeletons of the above prototyped functions, hollowed out in anticipation of being made operational.

Figure out what is going on, the connections, and make sure you understand it.

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

In unit/list/, you will find these new files:

Enhancements to these unit tests may be provided via dll0 project updates.

There are also corresponding verify-FUNCTION.sh scripts that will output a “MATCH”/“MISMATCH” to confirm overall conformance with the pertinent list functionality.

These are complete runnable programs (when compiled, and linked against the list library, which is all handled for you by the Makefile system in place).

Of particular importance, I want you to take a close look at:

Expected Results

To assist you in verifying a correct implementation, a fully working implementation of the node and list libraries should resemble the following (when running the respective verify script):

list library

Here is what you should get for list:

lab46:~/src/data/dll0$ bin/verify-list.sh 
====================================================
=    Verifying Doubly-Linked List Functionality    =
====================================================
  [mklist] Total:  12, Matches:  12, Mismatches:   0
  [cplist] Total:  18, Matches:  18, Mismatches:   0
  [append] Total:  36, Matches:  36, Mismatches:   0
  [insert] Total:  36, Matches:  36, Mismatches:   0
 [display] Total:  12, Matches:  12, Mismatches:   0
    [find] Total:  28, Matches:  28, Mismatches:   0
====================================================
 [RESULTS] Total: 142, Matches: 142, Mismatches:   0
====================================================
lab46:~/src/data/dll0$ 

Submission Criteria

To be successful in this project, the following criteria must be met: