chain.h - CPSC 221 Summer 2018 Doubly Linked List(PA 1 with head and tail pointers#ifndef_CHAIN_H#define_CHAIN_H#include <algorithm>#include

chain.h - CPSC 221 Summer 2018 Doubly Linked List(PA 1 with...

This preview shows page 1 - 3 out of 5 pages.

/** * * CPSC 221 Summer 2018 * Doubly Linked List (PA 1) * with head and tail pointers. * */ #ifndef _CHAIN_H_ #define _CHAIN_H_ #include <algorithm> #include <iostream> #include "block.h" using namespace std; /** * Chain: This is a container class for blocks. It is implemented * as a linked list of nodes, each of which contains a block. * * You should not remove anything from this class definition, but * you will find it helpful to add your own private helper functions to it. */ class Chain { private: /** * The Node class is private to the List class via the principle of * encapsulation---the end user does not need to know our node-based * implementation details. */ class Node { public: Node(); // default constructor--GIVEN Node(const Block & ndata); // data provided constructor--GIVEN Node * next; // pointer to next node in chain if one exists, or NULL Node * prev; // pointer to prev node in chain if one exists, or NULL const Block data; // data held by Node. must stay const for this assignment }; public: /* =============== public given functions ====================*/ /** * Default Chain constructor. GIVEN * Creates an empty Chain. Implemented for you. * Note that in this implementation, the empty chain consists of a head * sentinel node and a tail sentinel node, and no data between. * @see chain_given.cpp */ Chain(); /** * Constructor that breaks the given PNG into * rows x cols blocks and builds a chain of those * blocks. This constructor is GIVEN * @see chain_given.cpp */ Chain(PNG & imIn, int rows, int cols);
Image of page 1
/** * Copy constructor for a Chain. GIVEN * Since Chains allocate dynamic memory (i.e., they use "new", we * must define the Big Three). This depends on your implementation * of the copy funtion.
Image of page 2
Image of page 3

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture