next up previous contents
Next: Protected Members Up: The List Class Previous: The List Class

Public Members

tex2html_wrap_inline7610 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.

tex2html_wrap_inline7610 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.

tex2html_wrap_inline7610 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.

tex2html_wrap_inline7610 int is_empty(): If the linked list contains no elements, this member function will return non-zero; otherwise, it will return zero.

tex2html_wrap_inline7610 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.



Donald Craig
Mon Jul 8 12:05:35 NDT 1996