chain.cpp - #include\"chain.h#include\"chain_given.cpp PA1 functions Destroys the current Chain This function should ensure that memory does not leak on

chain.cpp - #include"chain.h#include"chain_given.cpp PA1...

This preview shows page 1 - 2 out of 2 pages.

#include "chain.h" #include "chain_given.cpp" // PA1 functions /** * Destroys the current Chain. This function should ensure that * memory does not leak on destruction of a chain. */ Chain::~Chain(){ /* your code here */ } /** * Inserts a new node at the end of the List. * This function **SHOULD** create a new ListNode. * * @param ndata The data to be inserted. */ void Chain::insertBack(const Block & ndata){ /* your code here */ } /** * Modifies the Chain by moving the subchain of len Nodes, * starting at position startPos, dist positions toward the * end of the chain. If startPos + len - 1 + dist > length * then dist = length - startPos - len + 1 (to prevent gaps * in the new chain). * The subchain occupies positions (startPos + dist) through * (startPos + dist + len - 1) of the resulting chain. * The order of subchain nodes is not changed in the move. * You may assume that: 1 <= startPos <= length - len + 1, * 0 <= dist <= length, and 0 <= len <= length. */ void Chain::moveBack(int startPos, int len, int dist){ /* your code here */ } /** * Rolls the current Chain by k nodes: reorders the current list * so that the first k nodes are the (n-k+1)th, (n-k+2)th, ... , nth * nodes of the original list followed by the 1st, 2nd, ..., (n-k)th
Image of page 1
Image of page 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture