Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 13.59.89.140
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : queue.js
function Queue () {
  this.head = new Item('head', null)
}
module.exports = Queue

Queue.prototype.append = function append (kind, value) {
  var item = new Item(kind, value)
  this.head.prepend(item)
  return item
}

Queue.prototype.isEmpty = function isEmpty () {
  return this.head.prev === this.head
}

Queue.prototype.first = function first () {
  return this.head.next
}

function Item (kind, value) {
  this.prev = this
  this.next = this
  this.kind = kind
  this.value = value
}

Item.prototype.prepend = function prepend (other) {
  other.prev = this.prev
  other.next = this
  other.prev.next = other
  other.next.prev = other
}

Item.prototype.dequeue = function dequeue () {
  var prev = this.prev
  var next = this.next

  prev.next = next
  next.prev = prev
  this.prev = this
  this.next = this

  return this.value
}

Item.prototype.isEmpty = function isEmpty () {
  return this.prev === this
}
© 2025 GrazzMean-Shell