📄 listtraverseruos.java
字号:
/* ListTraverserUos.java
* ---------------------------------------------
* Copyright (c) 2001 University of Saskatchewan
* All Rights Reserved
* --------------------------------------------- */
package dslib.list;
import dslib.base.*;
import dslib.exception.*;
/** Base class for processing every item in a list.
Subclasses need only define itemAction. */
public abstract class ListTraverserUos
{
/** Actions to be performed before each traversal. <br>
Analysis: Time = O(1) */
public void beforeActions()
{
}
/** Actions to be performed after each traversal. <br>
Analysis: Time = O(1) */
public void afterActions()
{
}
/** Call itemAction for every item in the list. <br>
Analysis: Time = O(n), where n = number of nodes
@param target position of item to be processed */
public void process(LinearIteratorUos target)
{
beforeActions();
target.goFirst();
while (target.itemExists())
{
itemAction(target.item());
target.goForth();
}
afterActions();
}
/** Perform an action on the specified item.
@param item item to perform the action on */
public abstract void itemAction(Object item);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -