<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.lensovet.net/~sysadmin/w/index.php?action=history&amp;feed=atom&amp;title=Computer_Science%2F61b%2FProjects%2FOcean%2FDList.java</id>
	<title>Computer Science/61b/Projects/Ocean/DList.java - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.lensovet.net/~sysadmin/w/index.php?action=history&amp;feed=atom&amp;title=Computer_Science%2F61b%2FProjects%2FOcean%2FDList.java"/>
	<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Projects/Ocean/DList.java&amp;action=history"/>
	<updated>2026-05-03T00:53:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Projects/Ocean/DList.java&amp;diff=24419&amp;oldid=prev</id>
		<title>Lensovet: Lensovet moved page CS/61b/Projects/Ocean/DList.java to Computer Science/61b/Projects/Ocean/DList.java</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Projects/Ocean/DList.java&amp;diff=24419&amp;oldid=prev"/>
		<updated>2023-02-20T03:51:36Z</updated>

		<summary type="html">&lt;p&gt;Lensovet moved page &lt;a href=&quot;/~sysadmin/w/CS/61b/Projects/Ocean/DList.java&quot; class=&quot;mw-redirect&quot; title=&quot;CS/61b/Projects/Ocean/DList.java&quot;&gt;CS/61b/Projects/Ocean/DList.java&lt;/a&gt; to &lt;a href=&quot;/~sysadmin/w/Computer_Science/61b/Projects/Ocean/DList.java&quot; title=&quot;Computer Science/61b/Projects/Ocean/DList.java&quot;&gt;Computer Science/61b/Projects/Ocean/DList.java&lt;/a&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 03:51, 20 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Projects/Ocean/DList.java&amp;diff=3957&amp;oldid=prev</id>
		<title>Lensovet: moved CS 61b/Projects/Ocean/DList.java to CS/61b/Projects/Ocean/DList.java:&amp;#32;fix CS 61b hierarchy</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Projects/Ocean/DList.java&amp;diff=3957&amp;oldid=prev"/>
		<updated>2010-11-14T05:59:46Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/~sysadmin/w/CS_61b/Projects/Ocean/DList.java&quot; class=&quot;mw-redirect&quot; title=&quot;CS 61b/Projects/Ocean/DList.java&quot;&gt;CS 61b/Projects/Ocean/DList.java&lt;/a&gt; to &lt;a href=&quot;/~sysadmin/w/CS/61b/Projects/Ocean/DList.java&quot; class=&quot;mw-redirect&quot; title=&quot;CS/61b/Projects/Ocean/DList.java&quot;&gt;CS/61b/Projects/Ocean/DList.java&lt;/a&gt;: fix CS 61b hierarchy&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 05:59, 14 November 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Projects/Ocean/DList.java&amp;diff=2237&amp;oldid=prev</id>
		<title>Lensovet at 03:11, 14 November 2006</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Projects/Ocean/DList.java&amp;diff=2237&amp;oldid=prev"/>
		<updated>2006-11-14T03:11:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{code}}&lt;br /&gt;
 /* DList.java */&lt;br /&gt;
 &lt;br /&gt;
 /**&lt;br /&gt;
  *  The DList class is a doubly-linked implementation of the linked list&lt;br /&gt;
  *  abstraction.  DLists are mutable data structures, which can grow at either&lt;br /&gt;
  *  end.&lt;br /&gt;
  *&lt;br /&gt;
  *  This class is incomplete and only includes the methods necessary for the Oceans project&lt;br /&gt;
  **/&lt;br /&gt;
 &lt;br /&gt;
 public class DList {&lt;br /&gt;
 	private DListNode head;&lt;br /&gt;
 	// we have to make this non-private so that we can manipulate size directly when we call addShark() and addFish() on a RLE&lt;br /&gt;
 	// (at least it makes those manipulations easier)&lt;br /&gt;
 	int size;&lt;br /&gt;
 	// Ocean-specific fields&lt;br /&gt;
 	int dimx;&lt;br /&gt;
 	int dimy;&lt;br /&gt;
 	int starvetime;&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 *  DList() constructs an empty list.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	&lt;br /&gt;
 	public DList() {&lt;br /&gt;
 		size = 0;&lt;br /&gt;
 		head = new DListNode();&lt;br /&gt;
 		head.next = head;&lt;br /&gt;
 		head.prev = head;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 * Ocean-specific: constructs a new list representing an i by j ocean where sharks die according to starve&lt;br /&gt;
 	 * set size, dimx, and dimy appropriately; set starvetime to starve param&lt;br /&gt;
 	 **/&lt;br /&gt;
 	&lt;br /&gt;
 	public DList(int i, int j, int starve) {&lt;br /&gt;
 		size = 0;&lt;br /&gt;
 		head = new DListNode();&lt;br /&gt;
 		head.next = head;&lt;br /&gt;
 		head.prev = head;&lt;br /&gt;
 		dimx = i;&lt;br /&gt;
 		dimy = j;&lt;br /&gt;
 		starvetime = starve;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 *  isEmpty() indicates whether the list is empty.&lt;br /&gt;
 	 *  @return true if the list is empty, false otherwise.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	&lt;br /&gt;
 	public boolean isEmpty() {&lt;br /&gt;
 		return size == 0;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 *  length() returns the length of this list.&lt;br /&gt;
 	 *  @return the length of this list.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	&lt;br /&gt;
 	public int length() {&lt;br /&gt;
 		return size;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 *  insertFront() inserts a block of cells at the beginning of this list.&lt;br /&gt;
 	 *  @param type the type of cell to be inserted.&lt;br /&gt;
 	 *	@param frequency the number of consecutive cells of this type&lt;br /&gt;
 	 **/&lt;br /&gt;
 	&lt;br /&gt;
 	public void insertFront(int type, int frequency, int hunger) {&lt;br /&gt;
 		DListNode item = new DListNode(type);&lt;br /&gt;
 		head.next.prev = item;&lt;br /&gt;
 		item.next = head.next;&lt;br /&gt;
 		item.prev = head;&lt;br /&gt;
 		head.next = item;&lt;br /&gt;
 		item.consecs = frequency;&lt;br /&gt;
 		item.hunger = hunger;&lt;br /&gt;
 		size++;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 *  insertEnd() inserts item &amp;quot;obj&amp;quot; at the end of this list.&lt;br /&gt;
 	 *  @param type the type of cell to be inserted.&lt;br /&gt;
 	 *	@param frequency the number of consecutive cells of this type&lt;br /&gt;
 	 **/&lt;br /&gt;
 	&lt;br /&gt;
 	public void insertEnd(int type, int frequency, int hunger) {&lt;br /&gt;
 		DListNode item = new DListNode(type);&lt;br /&gt;
 		head.prev.next = item;&lt;br /&gt;
 		item.next = head;&lt;br /&gt;
 		item.prev = head.prev;&lt;br /&gt;
 		head.prev = item;&lt;br /&gt;
 		item.consecs = frequency;&lt;br /&gt;
 		item.hunger = hunger;&lt;br /&gt;
 		size++;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	public void insertEnd(int type, int frequency) {&lt;br /&gt;
 		insertEnd(type, frequency, 0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	public void insertFront(int type, int frequency) {&lt;br /&gt;
 		insertFront(type, frequency, 0);&lt;br /&gt;
 	}&lt;br /&gt;
 &lt;br /&gt;
 	/**&lt;br /&gt;
 	 *  nth() returns the NODE at the specified position.  If position &amp;lt; 1 or&lt;br /&gt;
 	 *  position &amp;gt; this.length(), null is returned.  Otherwise, the item at&lt;br /&gt;
 	 *  position &amp;quot;position&amp;quot; is returned.  The list does not change.&lt;br /&gt;
 	 *  @param position the desired position, from 1 to length(), in the list.&lt;br /&gt;
 	 *  @return the NODE at the given position in the list - this allows us to call .next and .prev on the returned value&lt;br /&gt;
 	 **/&lt;br /&gt;
 	&lt;br /&gt;
 	public DListNode nth(int position) {&lt;br /&gt;
 		DListNode currentNode;&lt;br /&gt;
 		if ((position &amp;lt; 1) || (head.next == head)) {&lt;br /&gt;
 			return null;&lt;br /&gt;
 		} else {&lt;br /&gt;
 			currentNode = head.next;&lt;br /&gt;
 			while (position &amp;gt; 1) {&lt;br /&gt;
 				currentNode = currentNode.next;&lt;br /&gt;
 				if (currentNode == head) {&lt;br /&gt;
 					return null;&lt;br /&gt;
 				}&lt;br /&gt;
 				position--;&lt;br /&gt;
 			}&lt;br /&gt;
 			return currentNode;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
</feed>