Difference between revisions of "Computer Science/61b/Projects/Ocean/DListNode.java"
< Computer Science | 61b | Projects | Ocean
m (Lensovet moved page CS/61b/Projects/Ocean/DListNode.java to Computer Science/61b/Projects/Ocean/DListNode.java) |
|
(One intermediate revision by the same user not shown) | |
(No difference)
|
Latest revision as of 03:51, 20 February 2023
- This page contains computer code. Unlike all articles on the lensowiki, which are released under the GFDL, this code is released under the GPL.
Copyright 2006, 2007 Paul Borokhov. All rights reserved.
This code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
The code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/* DListNode.java */ /** * DListNode is a class used internally by the DList class. A DList object * is a doubly-linked list, and a DListNode is a node of a doubly-linked * list. Each DListNode normally has three references: one to an object, one to * the next node in the list, and another to the previous node in the list. * * However, for purposes of the Ocean project this is changed as follows: * The item field is actually named type to better reflect the data that it holds * Consequently, the types are all ints and not objects * The number of fields is FIVE and not three - an additional field is added for the number of consecutive * cells of the given type and another for the shark's current hunger * */ class DListNode { int type; int hunger; int consecs; DListNode next; DListNode prev; /** * DListNode() (with two parameters) constructs a list node referencing the * item "obj", whose next list node is to be "next". */ DListNode(int type, int hunger, DListNode next) { this.type = type; this.hunger = hunger; this.next = next; } DListNode(int type, DListNode next) { this(type, 0, next); } DListNode(int type, int hunger) { this(type, hunger, null); } /** * DListNode() (with one parameter) constructs a list node referencing the * item "obj". **/ DListNode(int type) { this(type, null); } DListNode() { this(Ocean.EMPTY, null); } }