Skip to content

pos.Queue

Peter edited this page Mar 19, 2024 · 2 revisions

v1.8

Class: Queue

Instantiate a new queue

Constructor: _G.pos.Queue()

Instantiate a new network socket

Fields

Variable Description
__arr: any[] PRIVATE
__first: number PRIVATE
__last: number PRIVATE

Instance Functions

Signature Return Description
__init__() nil PACKAGE Initialize the queue
enqueue(item) nil Adds an item to the end of the queue
dequeue() any? Removes the first item from the queue and return it
peek() any? Return the fist item in the queue without removing it
size() number Get the number of items in the queue
clear() nil Clear all items from the queue

Detail

Functions

__init__

Queue:__init__(): nil

PACKAGE

Initialize the queue


enqueue

Queue:enqueue(item: any): nil

Adds an item to the end of the queue

Parameters

  • item: any

dequeue

Queue:dequeue(): any?

Removes the first item from the queue and return it

Returns

  • item: any?

peek

Queue:peek(): any?

Return the fist item in the queue without removing it

Returns

  • item: any?

size

Queue:size(): number

Get the number of items in the queue

Returns

  • size: number

clear

Queue:clear(): number

Clear all items from the queue


Clone this wiki locally