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

📄 bilinkediteratoruos.java

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

import dslib.exception.*;
import dslib.base.*;

/**	A LinkedIteratorUos which has functions to move forward and back, 
	and to the first and last items of the list.  It keeps track of 
	the current item, and also has functions to determine if it is 
	before the start or after the end of the list. */
public class BilinkedIteratorUos extends LinkedIteratorUos implements BilinearIteratorUos
{

	/**	Constructor creates a new iterator for list 'list'. <br>
		Analysis : Time = O(1) 
		@param list list to be iterated */
	public BilinkedIteratorUos(BilinkedListUos list)
	{
		super(list);
	}
	
	/**	Go to the last item of the data structure. <br> 
		Analysis: Time = O(1) */
	public void  goLast()
	{
		cur = ((BilinkedListUos)list).lastNode();
		if (cur==null)
			prev = null;
		else
			prev = ((BilinkedNodeUos)cur).previousNode();
	}

	/**	Move back one item in the data structure. <br> 
		Analysis: Time = O(1) <br>
		PRECONDITION:  <br>
		<ul>
			!before() 
		</ul>  */
	public void goBack() throws BeforeTheStartUosException
	{
		if (before())
			throw new BeforeTheStartUosException("Cannot move back since already before().");
		
		if (after())
			goLast();
		else
		{
			cur = ((BilinkedNodeUos)cur).previousNode();
			if (cur!=null)
				prev = ((BilinkedNodeUos)cur).previousNode();
		}
	 }
	  
} 

⌨️ 快捷键说明

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