public class MiniStack<E> extends Object
| Constructor and Description |
|---|
MiniStack()
Create a new empty stack with 8 elements capacity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Empties the stack.
|
boolean |
isEmpty()
Checks if we have any element at all on the stack.
|
E |
peek()
Returns the top/last element without removing
it.
|
E |
pop()
Removes and returns the last element
|
void |
push(E element)
Add a new element on top of the stack.
|
void |
reset()
Resets the stack to zero but does not
clean it.
|
int |
size()
Returns the current size of the stack.
|
public MiniStack()
A reference are typically (less than 32 GB memory) 4 bytes. The overhead of any object is about 24 bytes, give or take, hence 8*4 + 24 fits a cache line of 64 bytes.
public void clear()
public void reset()
public E pop()
public E peek()
public void push(E element)
element - the element to addpublic boolean isEmpty()
public int size()
Copyright © 2024 HtmlUnit. All rights reserved.