Doubly linked node

Requirements

In this sub-project, you will implement the nested class Double_node.

A doubly linked node contains three member variables: a value and two pointers, each of which point to another doubly linked node. Figure 1 shows a doubly linked list which contains three nodes.

Figure 1. A doubly linked list three nodes.

Class Specifications

UML Class Diagram

Double_node
+ node_value:Type
+ previous_node:Double_node
+ next_node:Double_node
+ create( in obj:Type = Type(), in p:Double_node = nullptr, in n:Double_node = nullptr ):Double_node
+ value():Type
+ previous():Double_node
+ next():Double_node


Description

A nested class which stores an object, a pointer to the next node in a linked list, and a pointer to the previous node in the linked list.

Member Variables

The three member variables are:

  • An Type referred to as the value of the node,
  • A pointer to a Double_node referred to as the next pointer, and
  • A pointer to a Double_node referred to as the previous pointer.

Member Functions

Constructors

Double_node( Type const &, Double_node *, Double_node * )

This constructor takes three arguments: a constant reference to an Type (by default, a new instance of the class Type) and two pointers to a Double_node (each by default nullptr). These are assigned to the member variables, respectively. (O(1))

Destructor

This class uses the default destructor.

Copy Constructor

This class uses the default copy constructor.

Move Constructor

This class uses the default copy constructor.

Accessors

This class has three accessors, one to get each of the three associated member variables:

Type value() const
Returns the value of the node. (O(1))
Double_node *next() const
Returns the next pointer. (O(1))
Double_node *previous() const
Returns the previous pointer. (O(1))

Mutators

This class has no member functions which modify the member variables.

Friends

This class has no friends.

Typename

Because this is a nested class within a doubly-linked list class, if a local variable is to be declared to be of this type, the following notation must be used:

 
	typename Containing_class_name<int>::Double_node local_variable;