Open main menu

lensowiki β

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

< Computer Science‎ | 61b‎ | Homework‎ | hw5‎ | list
/* 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.