[Current] [News] [Glance] [Search] [Instructions] [Links] [Handouts] [Project] [Outlines] [Labs] [Homeworks] [Quizzes] [Exams] [Examples] [EIJ] [API]
Back to Iterating Array-Based Lists. On to Linked Lists, Continued.
Held Tuesday, November 7, 2000
Summary
Today we consider how to implement lists using nodes that are similar to the cons cells (pairs) that you saw in Scheme.
Notes
Overview
Node
class.
/** * Nodes for a linked list. */ protected class Node { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The contents of the current node. Can never be null. */ Object contents; /** A link to the next node. Set to null if this is the last node. */ Node next; } // class Node
/** * A linked list. */ public class LinkedList { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The first element of the list. Set to null for empty lists. */ Node first; /** The last element of the list. Set to null for empty lists. */ Node last; /** The length of the list. Easier to store in a field than recompute. */ int length; } // class LinkedList
Wednesday, 23 August 2000
Thursday, 24 August 2000
Tuesday, 7 November 2000
Back to Iterating Array-Based Lists. On to Linked Lists, Continued.
[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.39.html
Source text last modified Tue Nov 7 08:45:11 2000.
This page generated on Tue Nov 7 08:54:44 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu