ordereddictcursoruos.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 53 行

JAVA
53
字号
/* OrderedDictCursorUos.java
 * ---------------------------------------------
 * Copyright (c) 2001 University of Saskatchewan
 * All Rights Reserved
 * --------------------------------------------- */

package dslib.dictionary.bintree;

import dslib.base.*;
import dslib.dispenser.LinkedStackUos;


/**	A cursor that has a current item, a previous item, and a 
	stack of items yet to visit. */
public class OrderedDictCursorUos implements CursorUos
{
	/**	The stack of items yet to visit */
	public LinkedStackUos theStack;

	/**	The current item */
	public HtBalNodeUos cur;

	/**	The previous item */
	public HtBalNodeUos parent;

	/**	Create a new cursor for an ordered dictionary. <br>
		Analysis: Time = O(1) */
	public OrderedDictCursorUos(HtBalNodeUos newCur, HtBalNodeUos newParent, LinkedStackUos newTheStack)
	{
		theStack = newTheStack;
		cur = newCur;
		parent = newParent;
	}

	/**	Is there a current item?. <br>
		Analysis: Time = O(1) */
	public boolean itemExists()
	{
		return cur!=null;
	}

	/**	The current item. <br>
		Anlaysis: Time = O(1) <br>
		PRECONDITION: <br>
		<ul>
			itemExists()
		</ul> */
	public Object item()
	{
		return cur.item();
	}
}

⌨️ 快捷键说明

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