Advertisement
Guest User

Fila.js

a guest
Aug 26th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //JavaScript FIFO
  2. function Fila(){
  3. this.lista = new Array();
  4.  
  5. this.Inserir = function(obj){
  6. //Inserir no fim da fila um elemento
  7. this.lista[this.lista.length] = obj;
  8. }
  9.  
  10. this.Remover = function() {
  11. //Remove o primeiro elemento
  12. if(this.lista.length>0){
  13. this.lista.splice(0,1);
  14. }else{
  15. alert("Não há objetos na Fila");
  16. }
  17. }
  18.  
  19. this.Escrever = function(){
  20. elem = this.lista.length;
  21. document.write("<b>Escrevendo FIFO</b></br>");
  22. if(elem>0){
  23. cont = 0;
  24. for(cont=0;cont<elem;cont++){
  25. document.write(
  26. this.lista[cont]+"<br>");
  27. }
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement