Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents index

Accessor Methods

Three LinkedList accessors are defined in Program gif. 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).

   program3743
Program: LinkedList class accessor methods.


next up previous contents index

Bruno Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.