Skip to main content

BinaryHeap

This is a class I took from something Rust related. You can read its documentation info here.

Properties

ComparisonFunction

BinaryHeap.ComparisonFunction: ComparisonFunction<Comparable>?

The ComparisonFunction of the BinaryHeap.

Length

BinaryHeap.Length: int

The Length of the BinaryHeap.

Functions

new

BinaryHeap.new(
ComparisonFunction: ComparisonFunction<Comparable>?--

The comparison function.

) → BinaryHeap<T>

Creates a new BinaryHeap.

Push

BinaryHeap:Push(
Key: Comparable--

The key you are pushing. Must be able to work with comparing methods like <.

) → int--

The index of the pushed key in the heap.

Pushes a new key to the heap.

Pop

BinaryHeap:Pop() → Comparable?--

The minimum element if it exists, otherwise nil.

Removes the minimum element (the root) from the heap and returns it.

Delete

BinaryHeap:Delete(
Index: int--

The index of the key you want to delete.

) → BinaryHeap<T>--

Returns the same heap.

Deletes the key at Index by shifting it to root (treating it as -infinity) and then popping it.

GetFront

BinaryHeap:GetFront() → T--

The first value.

Returns the front value of the heap.

IsEmpty

BinaryHeap:IsEmpty() → boolean-Trueifftheheapisempty.

Determines if the heap is empty.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new BinaryHeap.",
            "params": [
                {
                    "name": "ComparisonFunction",
                    "desc": "The comparison function.",
                    "lua_type": "ComparisonFunction<Comparable>?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "BinaryHeap<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 36,
                "path": "src/DataStructures/BinaryHeap/init.lua"
            }
        },
        {
            "name": "Push",
            "desc": "Pushes a new key to the heap.",
            "params": [
                {
                    "name": "Key",
                    "desc": "The key you are pushing. Must be able to work with comparing methods like `<`.",
                    "lua_type": "Comparable"
                }
            ],
            "returns": [
                {
                    "desc": "The index of the pushed key in the heap.",
                    "lua_type": "int"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 94,
                "path": "src/DataStructures/BinaryHeap/init.lua"
            }
        },
        {
            "name": "Pop",
            "desc": "Removes the minimum element (the root) from the heap and returns it.",
            "params": [],
            "returns": [
                {
                    "desc": "The minimum element if it exists, otherwise nil.",
                    "lua_type": "Comparable?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 169,
                "path": "src/DataStructures/BinaryHeap/init.lua"
            }
        },
        {
            "name": "Delete",
            "desc": "Deletes the key at Index by shifting it to root (treating it as -infinity) and then popping it.",
            "params": [
                {
                    "name": "Index",
                    "desc": "The index of the key you want to delete.",
                    "lua_type": "int"
                }
            ],
            "returns": [
                {
                    "desc": "Returns the same heap.",
                    "lua_type": "BinaryHeap<T>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 226,
                "path": "src/DataStructures/BinaryHeap/init.lua"
            }
        },
        {
            "name": "GetFront",
            "desc": "Returns the front value of the heap.",
            "params": [],
            "returns": [
                {
                    "desc": "The first value.",
                    "lua_type": "T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 282,
                "path": "src/DataStructures/BinaryHeap/init.lua"
            }
        },
        {
            "name": "IsEmpty",
            "desc": "Determines if the heap is empty.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean - True iff the heap is empty."
                }
            ],
            "function_type": "method",
            "source": {
                "line": 292,
                "path": "src/DataStructures/BinaryHeap/init.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "ComparisonFunction",
            "desc": "The ComparisonFunction of the BinaryHeap.",
            "lua_type": "ComparisonFunction<Comparable>?",
            "source": {
                "line": 23,
                "path": "src/DataStructures/BinaryHeap/init.lua"
            }
        },
        {
            "name": "Length",
            "desc": "The Length of the BinaryHeap.",
            "lua_type": "int",
            "source": {
                "line": 30,
                "path": "src/DataStructures/BinaryHeap/init.lua"
            }
        }
    ],
    "types": [],
    "name": "BinaryHeap",
    "desc": "This is a class I took from something Rust related. You can read its documentation info [here](https://doc.rust-lang.org/stable/std/collections/struct.BinaryHeap.html).",
    "source": {
        "line": 7,
        "path": "src/DataStructures/BinaryHeap/init.lua"
    }
}