Data Structures and Algorithms
with Object-Oriented Design Patterns in Java
Three LinkedList accessors are defined in Program
.
The methods getHead and getTail
provide read-only access to the corresponding fields of LinkedList.
The method isEmpty returns a boolean result
which indicates whether the list is empty.
Clearly, the running time of each accessor is O(1).

Program: LinkedList class accessor methods.
Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.