Skip to main content

Queue

A generic Queue class for Luau.

Properties

ClassName

Queue.ClassName: "Queue"

Functions

new

static
Queue.new() → Queue<T>

Creates a new Queue

__tostring

metamethod
Queue:__tostring() → string

Converts the Queue into a string.

iterating over Queue

for  _,valueT  in  Queue  do

IsEmpty

Queue:IsEmpty() → boolean

Check if the queue is empty.

Peek

Queue:Peek() → T?

Look at the first value in the queue.

Pop

Queue:Pop() → T?

Remove the value at the front of the queue if there is one.

Has

Queue:Has(valueT) → boolean

Checks to see if a given value exists within the Queue.

Size

Queue:Size() → number

Get the number of items in the Queue.

Append

Queue:Append(valueT) → ()

Add a value to the back of the queue.

Prepend

Queue:Prepend(valueT) → ()

Add a value to the front of the queue.

ToArray

Queue:ToArray() → {T}

Converts the Queue into an iterable array.

RemoveFirstOccurence

Queue:RemoveFirstOccurence(valueT) → boolean

Removes the first occurence of a given value in the queue. Returns whether or not it did remove something.

RemoveItemAt

Queue:RemoveItemAt(
indexnumber--

The index of the item to remove.

) → (
boolean,--

Whether or not it did remove something.

T?--

The item that was removed.

)

Removes the item at the given index. Returns whether or not it did remove something. If it did, it will also return the item that was removed. This method should typically only be used in conjunction with the iterator metamethod.

Show raw api
{
    "functions": [
        {
            "name": "__tostring",
            "desc": "Converts the Queue into a string.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "tags": [
                "metamethod"
            ],
            "source": {
                "line": 38,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "__iter",
            "desc": "",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "_, value: T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 47,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "new",
            "desc": "Creates a new Queue",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Queue<T>\n"
                }
            ],
            "function_type": "static",
            "tags": [
                "static"
            ],
            "source": {
                "line": 61,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "IsEmpty",
            "desc": "Check if the queue is empty.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 72,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "Peek",
            "desc": "Look at the first value in the queue.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T?\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 79,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "Pop",
            "desc": "Remove the value at the front of the queue if there is one.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T?\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 86,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "Has",
            "desc": "Checks to see if a given value exists within the Queue.",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 100,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "Size",
            "desc": "Get the number of items in the Queue.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 112,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "Append",
            "desc": "Add a value to the back of the queue.",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 119,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "Prepend",
            "desc": "Add a value to the front of the queue.",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 128,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "ToArray",
            "desc": "Converts the Queue into an iterable array.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{T}\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 137,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "RemoveFirstOccurence",
            "desc": "Removes the first occurence of a given value in the queue. Returns whether or not it did remove something.",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 148,
                "path": "src/queue/src/Queue.lua"
            }
        },
        {
            "name": "RemoveItemAt",
            "desc": "Removes the item at the given index. Returns whether or not it did remove something.\nIf it did, it will also return the item that was removed. This method should typically\nonly be used in conjunction with the iterator metamethod.",
            "params": [
                {
                    "name": "index",
                    "desc": "The index of the item to remove.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "Whether or not it did remove something.",
                    "lua_type": "boolean"
                },
                {
                    "desc": "The item that was removed.",
                    "lua_type": "T?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 185,
                "path": "src/queue/src/Queue.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "ClassName",
            "desc": "",
            "lua_type": "\"Queue\"",
            "source": {
                "line": 30,
                "path": "src/queue/src/Queue.lua"
            }
        }
    ],
    "types": [],
    "name": "Queue",
    "desc": "A generic Queue class for Luau.",
    "source": {
        "line": 8,
        "path": "src/queue/src/Queue.lua"
    }
}