Open main menu

lensowiki β

Computer Science/61b/Homework/hw5/list/SList.java

< Computer Science‎ | 61b‎ | Homework‎ | hw5‎ | list
Revision as of 03:51, 20 February 2023 by Lensovet (talk | contribs) (Lensovet moved page CS/61b/Homework/hw5/list/SList.java to Computer Science/61b/Homework/hw5/list/SList.java)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/* SList.java */

package list;

/**
 *  A SList is a mutable singly-linked list ADT.  Its implementation employs
 *  a tail reference.
 *
 *  DO NOT CHANGE THIS FILE.
 **/

public class SList extends List {

  /**
   *  (inherited)  size is the number of items in the list.
   *  head references the first node.
   *  tail references the last node.
   **/

  protected SListNode head;
  protected SListNode tail;

  /* SList invariants:
   *  1)  Either head == null and tail == null, or tail.next == null and the
   *      SListNode referenced by tail can be reached from the head by a
   *      sequence of zero or more "next" references.  This implies that the
   *      list is not circularly linked.
   *  2)  The "size" field is the number of SListNodes that can be accessed
   *      from head (including head itself) by a sequence of "next" references.
   *  3)  For any SListNode x in an SList l, x.myList = l.
   **/
The author of this file is Jonathan Shewchuk; consequently, I cannot make it freely available.