1) Consider implementing a multiset as a linked list that only has a head pointer. Overload the += operator to take another multiset as an argument and append copies of all the members of the argument to the current multiset.
a) describe the steps the function must take to implement this operator.
b) what is the running time of the += operation?
2)Consider a template class, DLListNode, used when implementing doubly linked lists. Create a complete header file for this class that contains at least.
-the macro guard
-default contructor
-a constructor that takes arguments that allow a node to be immediately linked into a list, similar to other node constructors
-a destructor
-member functions to set and retrieve the private data member values
-where appropriate use the const keyword and make the parameters and return value references
-a private data member called data of type T
-private data members that are links to the previous and next nodes in the doubly linked list
-all necessary #includes
for this question i have some parts not sure if they are right maybe someone can check
Code:
#ifndef DLListNode_H
#define DLListNode_H
#include <iostream>
//not sure if i should include anything else
template <class T>
class DLListNode
{
public:
DLListNode(); //default constructor
DLListNode(const T&);//constructor tht knows the data but not what it points to
DLListNode(const T&, DLListNode<T>*, DLListNode<T>*); //constructor that knows the data and the two pointer values
~DLListNode(); //class destructor
//what i need now are functions that set and retrieve the private data member values however i am unsure what this means
//because i think it would be the same thing as the constructors
private:
T data;
DLListNode<T>* nextPtr;
DLListNode<T>*prevPtr;
};
#include "DLListNode.template"