O código de fila dupla precisa ser reduzido
Existe alguma maneira de reduzir esse código para fazer a mesma coisa, mas com menos 100 caracteres?
É uma fila de borda dupla simples que tem pushHead, popHead, pushTail, popTail, bem como uma maneira de acessar o tamanho e isEmpty.
var makeDeque = function()
{
var a= [];
this.length= a.length=0;
this.pushHead=function(v)
{
a.unshift(v);
}
this.popHead=function()
{
return a.shift();
}
this.pushTail=function(v)
{
a.push(v);
}
this.popTail=function()
{
return a.pop();
}
this.isEmpty=function()
{
return a.length===0;
}
return this;
};
Obrigado!