Class LinkedListStack<T>
- java.lang.Object
-
- com.github.collinalpert.lambda2sql.LinkedListStack<T>
-
- Type Parameters:
T- The type of the Stack.
public class LinkedListStack<T> extends java.lang.ObjectCustom implementation of a stack that uses a linked list functionality approach.- Author:
- Collin Alpert
- See Also:
LinkedListStack.Node
-
-
Constructor Summary
Constructors Constructor Description LinkedListStack()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisEmpty()Checks if the stack is empty.Tpop()Pops (removes and returns) the top of the stack.voidpush(T element)Pushes (adds) an element to the top of the stack.intsize()Ttop()Returns the top of the stack.
-
-
-
Method Detail
-
push
public void push(T element)
Pushes (adds) an element to the top of the stack.- Parameters:
element- The element to be added.
-
pop
public T pop()
Pops (removes and returns) the top of the stack.- Returns:
- The top element on the stack.
-
top
public T top()
Returns the top of the stack.- Returns:
- The first element on the stack.
-
isEmpty
public boolean isEmpty()
Checks if the stack is empty.- Returns:
Trueif there are elements in the stack, otherwisefalse.
-
size
public int size()
- Returns:
- the number of elements in this stack.
-
-