[an error occurred while processing this directive] [an error occurred while processing this directive]
[an error occurred while processing this directive] Skip to the content of the web site.In this sub-project, you will implement and use two classes:
A singly-linked list with three nodes is shown in Figure 1. The empty list is shown in Figure 2.
Figure 1. A singly-linked list three nodes.
Figure 2. An empty singly-linked list.
SingleList |
---|
- list_head:SingleNode - list_tail:SingleNode - count:Integer |
+ create():SingleList + create( in sl:SingleList ):SingleList + =( in rhs:SingleList ):SingleList + size():Integer + empty():Boolean + front():Type + back():Type + head():SingleNode + tail():SingleNode + member( in obj:Type ):Boolean + push_front( in obj:Type ) + push_back( in obj:Type ) + pop_front():Type + remove( in obj:Type ):Boolean + destroy() |
This class stores a finite list of n (zero or more) elements stored in singly-linked nodes. If there are zero elements in the list, the list is said to be empty. Each element is stored in an instance of the SingleNode<Object> class. If the list is empty, the head and tail pointers are assigned 0. Otherwise, the head pointer points to the first node, the tail pointer points to the nth node, the next pointer of the ith node (1 ≤ i < n) points to the (i + 1)st node, and the next pointer of the nth is assigned 0.
The three class members are:
SingleList()
This constructor sets all class members to 0. (O(1))
The destructor must delete each of the nodes in the linked list. (O(n))
The copy constructor creates a new instance of the linked list. (O(n))
The assignment operator, if necessary, must delete all the nodes within the linked list being assigned to and add copies of the nodes in the linked list being assigned in the same order. (O(max{nlhs, nrhs}))
This class has seven accessors:
This class has four mutators:
Copyright ©2005-2008 by Douglas Wilhelm Harder. All rights reserved.