Deque - lnx00/Lmaobox-Library GitHub Wiki

Deque

Implementation of the double-ended queue data structure

Functions

  • .new(items?) Returns a new Deque instance. You can optionally pass some initial items as a table.

Methods

  • :pushFront(item)
  • :pushBack(item)
  • :popFront()
  • :popBack()
  • :peekFront()
  • :peekBack()
  • :empty() Returns if the deque is empty
  • :clear() Clears the deque
  • :size() Returns the amount of items in the deque
  • :items() Returns a read-only table with all items of the deque (for iterating etc.)

Example

local myDeque = Deque.new()
myDeque.pushBack("Hello")
myDeque.pushBack("World")

print(myDeque:popFront()) -- Prints "Hello"
print(myDeque:popFront()) -- Prints "World"