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:ImmutableStackCreates a new stack out of the element and appends the previous stack to it.- Specified by:
pushin interfaceImmutableStack<T>- Parameters:
element- to create a new stack from- Returns:
- new stack
-
pop
Description copied from interface:ImmutableStackReturns the tail of the current stack.- Specified by:
popin interfaceImmutableStack<T>- Returns:
- tail of current stack stack
-
peek
Description copied from interface:ImmutableStackSee the current element.- Specified by:
peekin interfaceImmutableStack<T>- Returns:
- current element
-
depth
public int depth()Description copied from interface:ImmutableStackThe depth of current stack.- Specified by:
depthin interfaceImmutableStack<T>- Returns:
- depth of current stack
-
isEmpty
public boolean isEmpty()Description copied from interface:ImmutableStackTrue if stack is empty.- Specified by:
isEmptyin interfaceImmutableStack<T>- Returns:
- true if stack is empty
-
iterator
-