List(): The List constructor initializes
the head and tail of the linked list to the null pointer and initializes
the number of elements currently in the list to zero.
add(const Type &item): This member function adds
the element specified by item to the linked list. Memory for
the new item is allocated from the free store and the element is
appended to the end of the linked list. The head and tail of the linked
list are updated accordingly and the internal counter maintaining the
number of elements in the linked list is incremented by one.
int num_elements(): This member function
returns a count of the number of elements currently in the linked list.
Because the List class maintains a count of the number of
list elements as new items are added, this member
function operates in constant time.
int is_empty(): If the linked list contains no
elements, this member function will return non-zero; otherwise, it will return
zero.
const Type *last_element(): Occasionally, an
implementation may wish to obtain the last item in a list. The
last_element() member function will return a pointer to the
last element of the list, or a null pointer if the list is empty.
This function operates in constant time since the
List class maintains a pointer to the last member of the
list.