Class ImmutableStackImpl<T>
java.lang.Object
com.abstractkamen.datastructures.impl.stacks.ImmutableStackImpl<T>
- Type Parameters:
T
- type of element
- All Implemented Interfaces:
ImmutableStack<T>
,Iterable<T>
This class is the non-empty implementation.
-
Constructor Details
-
ImmutableStackImpl
public ImmutableStackImpl()
-
-
Method Details
-
push
Description copied from interface:ImmutableStack
Creates a new stack out of the element and appends the previous stack to it.- Specified by:
push
in interfaceImmutableStack<T>
- Parameters:
element
- to create a new stack from- Returns:
- new stack
-
pop
Description copied from interface:ImmutableStack
Returns the tail of the current stack.- Specified by:
pop
in interfaceImmutableStack<T>
- Returns:
- tail of current stack stack
-
peek
Description copied from interface:ImmutableStack
See the current element.- Specified by:
peek
in interfaceImmutableStack<T>
- Returns:
- current element
-
depth
public int depth()Description copied from interface:ImmutableStack
The depth of current stack.- Specified by:
depth
in interfaceImmutableStack<T>
- Returns:
- depth of current stack
-
isEmpty
public boolean isEmpty()Description copied from interface:ImmutableStack
True if stack is empty.- Specified by:
isEmpty
in interfaceImmutableStack<T>
- Returns:
- true if stack is empty
-
iterator
-