[Current] [News] [Glance] [Search] [Instructions] [Links] [Handouts] [Project] [Outlines] [Labs] [Homeworks] [Quizzes] [Exams] [Examples] [EIJ] [API]
Back to Detour: Applets. On to Linked Lists.
Held Monday, November 6, 2000
Summary
Today we continue our consideration of array-based lists by building an iterator for those lists.
Notes
Overview
/** * Iterators for array-based lists. * * @author Samuel A. Rebelsky * @version 1.0 of November 2000 */ public class ArrayBasedListIterator { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** The underlying list that we're iterating. */ protected ArrayBasedList list; /** The curernt position in the list. */ int position; // +--------------+-------------------------------------------- // | Constructors | // +--------------+ /** Build a new iterator for a particular list. */ public ArrayBasedListIterator(ArrayBasedList base) { this.list = base; this.position = 0; } // ArrayBasedListIterator(ArrayBasedList) // +-----------+----------------------------------------------- // | Observers | // +-----------+ /** Get the current element. */ public Object getCurrent() { return this.list.elements[this.position]; } // getCurrent() // +-----------+----------------------------------------------- // | Modifiers | // +-----------+ } // class ArrayBasedListIterator
elements
field of ArrayBasedList
.
elements
field private
(or "package")?
ArrayBasedListIterator
a protected
class within the file ArrayBasedList.java
. Then it is
legal to build them from within ArrayBasedList
but not
elsewhere.
first
field.
last
field?
first
.
first
.
null
might represent a gap.
Wednesday, 23 August 2000
Thursday, 24 August 2000
Monday, 6 November 2000
Back to Detour: Applets. On to Linked Lists.
[Current] [News] [Glance] [Search] [Instructions] [Links] [Handouts] [Project] [Outlines] [Labs] [Homeworks] [Quizzes] [Exams] [Examples] [EIJ] [API]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2000F/Outlines/outline.38.html
Source text last modified Mon Nov 6 08:49:29 2000.
This page generated on Mon Nov 6 08:56:03 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu