⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linkednodeuos.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
/* LinkedNodeUos.java
 * ---------------------------------------------
 * Copyright (c) 2001 University of Saskatchewan
 * All Rights Reserved
 * --------------------------------------------- */
 
package dslib.list;

import java.io.Serializable;

/**	A basic linked node containing a generic item and a reference to 
	the next node.  There are routines for setting the item and next 
	node, and a toString routine that provides a string representation of 
	the list of nodes starting with the current node. */
public class LinkedNodeUos implements Serializable, Cloneable
{
	/**	Contents of the node. */
	protected Object item;
  
	/**	The next node. */
	protected LinkedNodeUos nextNode;

	/**	Construct a new node with item x. <br>
		Analysis: Time = O(1) 
		@param x item placed in the new node */
	public LinkedNodeUos(Object x)
	{
		setItem(x);
	}

	/**	Contents of node. <br>
		Analysis: Time = O(1) */
	public Object item()
	{
		return item;
	}

	/**	The next node. <br>
		Analysis: Time = O(1) */
	public LinkedNodeUos nextNode()
	{
		return nextNode;
	}
  
	/**	Set item equal to x. <br>
		Analysis: Time = O(1) 
		@param x item to replace the node's current item */
	public void setItem(Object x)
	{
		item = x;
	}
  
	/**	Set nextNode equal to x. <br>
		Analysis: Time = O(1) 
		@param x node set as the next node */
	public void setNextNode(LinkedNodeUos x)
	{
		nextNode = x;
	}
  
	/**	String representation suitable for output. <br>
		Analysis: Time = O(n), where n = number of nodes linked from this node */
	public String toString()
	{
		String result = item.toString();
		if (nextNode!=null)
			result += " " + nextNode;
		return result;
	}

	/**	A shallow clone of this object. <br> 
		Analysis: Time = O(1) */
	public Object clone()
	{
		try
		{
			return super.clone();
		} catch (CloneNotSupportedException e)
		{
			// Should not occur: implements Cloneable 
			e.printStackTrace();
 			return null;
		}
	}
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -