Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class StackSLL <ELEMENT> {
- SimpleLinkedList<ELEMENT> lista = new SimpleLinkedList<ELEMENT>();
- public StackSLL() {
- }
- public StackSLL(SimpleLinkedList<ELEMENT> lista) {
- super();
- this.lista = lista;
- }
- public boolean empty() {
- return this.lista.size() <= 0;
- }
- public ELEMENT peek() {
- if (this.empty()) {
- throw new RuntimeException("La pila está vacía...");
- }
- return this.lista.element();
- }
- public ELEMENT pop() {
- if (this.empty()) {
- throw new RuntimeException("La pila está vacía...");
- }
- return this.lista.removeFirst();
- }
- public ELEMENT push(ELEMENT element) {
- lista.addFirst(element);
- return this.lista.element();
- }
- public boolean search(Object object) {
- return lista.search(object);
- }
- public int size() {
- return this.lista.size();
- }
- public String toString() {
- return this.lista.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement