📄 arrayedstackuos.java
字号:
/* ArrayedStackUos.java
* ---------------------------------------------
* Copyright (c) 2001 University of Saskatchewan
* All Rights Reserved
* --------------------------------------------- */
package dslib.dispenser;
import dslib.base.BoundedUos;
import dslib.list.ArrayedBasicListUos;
/** A bounded implementation of Stack that uses an ArrayedBasicListUos to store the items. Item
refers to the top item of the stack, and it can be deleted. There are also methods to
insert items and check for empty. */
public class ArrayedStackUos extends StackUos implements BoundedUos
{
/** Create a new stack with capacity size. <br>
Analysis: Time = O(1)
@param size capcity of the stack */
public ArrayedStackUos(int size)
{
rep = new ArrayedBasicListUos(size);
}
/** Number of items in the stack. <br>
Analysis: Time = O(1) */
public int count()
{
return ((ArrayedBasicListUos)rep).count();
}
/** Number of items the stack can hold. <br>
Analysis: Time = O(1) */
public int capacity()
{
return ((ArrayedBasicListUos)rep).capacity();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -