Skip to main content

Queue

Queue class with better performance characteristics than table.remove()

local queue = Queue.new()
queue:PushRight("a")
queue:PushRight("b")
queue:PushRight("c")

while not queue:IsEmpty() do
    local entry = queue:PopLeft()
    print(entry) --> a, b, c
end

Functions

new

Queue.new() → Queue<T>

Constructs a new queue

__len

Queue:__len() → number

Gets the queues length

GetCount

Queue:GetCount() → number

Returns the count of the queue

PushLeft

Queue:PushLeft(valueT) → ()

Pushes an entry to the left of the queue

PushRight

Queue:PushRight(valueT) → ()

Pushes an entry to the right of the queue

PopLeft

Queue:PopLeft() → T

Pops an entry from the left of the queue

PopRight

Queue:PopRight() → T

Pops an entry from the right of the queue

IsEmpty

Queue:IsEmpty() → boolean

Returns true if the queue is empty

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new queue",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Queue<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 27,
                "path": "src/queue/src/Shared/Queue.lua"
            }
        },
        {
            "name": "__len",
            "desc": "Gets the queues length",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 39,
                "path": "src/queue/src/Shared/Queue.lua"
            }
        },
        {
            "name": "GetCount",
            "desc": "Returns the count of the queue",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 48,
                "path": "src/queue/src/Shared/Queue.lua"
            }
        },
        {
            "name": "PushLeft",
            "desc": "Pushes an entry to the left of the queue",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 56,
                "path": "src/queue/src/Shared/Queue.lua"
            }
        },
        {
            "name": "PushRight",
            "desc": "Pushes an entry to the right of the queue",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 65,
                "path": "src/queue/src/Shared/Queue.lua"
            }
        },
        {
            "name": "PopLeft",
            "desc": "Pops an entry from the left of the queue",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 74,
                "path": "src/queue/src/Shared/Queue.lua"
            }
        },
        {
            "name": "PopRight",
            "desc": "Pops an entry from the right of the queue",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 90,
                "path": "src/queue/src/Shared/Queue.lua"
            }
        },
        {
            "name": "IsEmpty",
            "desc": "Returns true if the queue is empty",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 106,
                "path": "src/queue/src/Shared/Queue.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Queue",
    "desc": "Queue class with better performance characteristics than table.remove()\n\n```lua\nlocal queue = Queue.new()\nqueue:PushRight(\"a\")\nqueue:PushRight(\"b\")\nqueue:PushRight(\"c\")\n\nwhile not queue:IsEmpty() do\n    local entry = queue:PopLeft()\n    print(entry) --> a, b, c\nend\n```",
    "source": {
        "line": 18,
        "path": "src/queue/src/Shared/Queue.lua"
    }
}