Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package filas;
- public class listaNode {
- Node front = null;
- Node back = null;
- public void enqueue(Node i) {
- if(front == null && back == null) {
- front = back = i;
- }else {
- back.setNext(i);
- i.setPrevious(back);
- back = i;
- }
- }
- public void dequeue() {
- if(front == null && back == null) {
- System.out.println("Lista vazia!!!!");
- }else {
- front = front.getNext();
- front.setPrevious(null);
- }
- }
- }
- //fila
- package filas;
- public class lista {
- int front = 0;
- int back = 0;
- int[] queue;
- int aux = 0;
- public lista() {
- queue = new int[4];
- }
- public void enqueue(int info) {
- if (back == 0) {
- queue[back] = info;
- back++;
- if (back == queue.length) {
- back = 0;
- }
- } else if (back == front) {
- System.out.println("Lista cheia!!!!!!");
- } else {
- queue[back] = info;
- back++;
- }
- }
- public int dequeue() {
- if (front == queue.length) {
- front = 0;
- } else if (front > back) {
- System.out.println("Lisa cheia!!!");
- } else {
- queue[front] = aux;
- queue[front] = 0;
- front++;
- }
- return aux;
- }
- }
- //
- package filas;
- public class Node {
- private int info;
- private Node next = null;
- private Node previous = null;
- public Node getNext() {
- return next;
- }
- public void setNext(Node next) {
- this.next = next;
- }
- public Node getPrevious() {
- return previous;
- }
- public void setPrevious(Node previous) {
- this.previous = previous;
- }
- public int getInfo() {
- return info;
- }
- public void setInfo(int info) {
- this.info = info;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement