listprinter.java

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

JAVA
39
字号
package simple;

/**	ListPrinter which prints the list as it is traversed.  The list output
	includes a leading (, commas between the items and a trailing ).  */
public class ListPrinter extends ListTraverser
{
	/**	Create a new list Traverser 
		Analysis: Time = O(1) */
	public ListPrinter() {}

	/**	Actions done to an item 
		Analysis: Time = O(1) */
	public void itemActions(Object item)
	{
		System.out.print(item);
	}

	/**	Actions to be performed before each traversal
		Analysis: Time = O(1) */
	public void beforeActions()
	{
		System.out.print("(");
	}

	/**	Actions to be performed between items 
		Analysis: Time = O(1) */
	public void betweenActions()
	{
		System.out.print(", ");
	}
      
	/**	Actions to be performed after a traversal 
		Analysis: Time = O(1) */
	public void afterActions()
	{
		System.out.print(")");
	}
} 

⌨️ 快捷键说明

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