Struct Node

Using the following UML diagram and class description, write a class named MyDLL which implements a pointer-based doubly linked list.

Class Attributes:

  • Node – a nested struct
    • i – stores an integer
    • next – the pointer that holds the memory address of the following node.
    • prev – the pointer that holds the memory address of the preceding node.
  • head – the pointer that holds the memory address of the head node (the first node in the list).
  • tail – the pointer that holds the memory address of the tail node (the last node in the list).
  • constructor – initializes head and tail to null.
  • destructor – frees all memory used by the list.
  • append – if there is enough memory, stores it’s argument in a new node and attaches that new node to the end of the list.
  • remove – searches for it’s argument in the list. Removes the first node it finds that contains a value matching it’s argument.
  • find – searches for it’s argument in the list. Returns true if it’s found, false otherwise.
  • clear – frees all memory used by the list. Ensures head and tail are set back to null.
  • print – prints the values stored in the list in order.
  • reverse – prints the values stored in the list in reverse order.

Notes:

  • The class does not interact with the user in any way, so no cin or cout statements.
  • All accessors should be marked const.
  • struct Node is nested in the class and is private.
  • Since the insert and append algorithms are incompatible, only implement the append algorithm.

Hints:

  • Save yourself some work by having the destructor call clear.
  • There is no isFull or isEmpty method in the class.

Submission Details:

  • Place your class in it’s own header file named MyDLL.h.
  • Submit only this file.
  • Be sure to include preprocess guards( #ifndef, #define, #endif).

Do you need help with this assignment or any other? We got you! Place your order and leave the rest to our experts.

Quality Guaranteed

Any Deadline

No Plagiarism