Skip to content

Data Stack

scripts/vscripts/alyxlib/data/stack.lua

Methods

Push

Push values to the stack.

Stack:Push(...)

Parameters

  • ...

Pop

Pop a number of items from the stack.

Stack:Pop(count)

Parameters

  • count (optional)
    number
    Default is 1

Returns - ...

Top

Peek at a number of items at the top of the stack without removing them.

Stack:Top(count)

Parameters

  • count (optional)
    number
    Default is 1

Returns - ...

Bottom

Peek at a number of items at the bottom of the stack without removing them.

Stack:Bottom(count)

Parameters

  • count (optional)
    number
    Default is 1

Returns - ...

Remove

Remove a value from the stack regardless of its position.

Stack:Remove(value)

Parameters

  • value
    any

MoveToTop

Move an existing value to the top of the stack. Only the first occurance will be moved.

Stack:MoveToTop(value)

Parameters

  • value
    any
    The value to move.

Returns - boolean True if value was found and moved.

MoveToBottom

Move an existing value to the bottom of the stack. Only the first occurance will be moved.

Stack:MoveToBottom(value)

Parameters

  • value
    any
    The value to move.

Returns - boolean True if value was found and moved.

Contains

Get if this stack contains a value.

Stack:Contains(value)

Parameters

  • value
    any

Returns - boolean

Length

Return the number of items in the stack.

Stack:Length()

Returns - integer

IsEmpty

Get if the stack is empty.

Stack:IsEmpty()

pairs

Helper method for looping.

Stack:pairs()

Returns

  • function

  • any[]

  • number
    i

Functions

Stack

Create a new Stack object. First value is at the top.

E.g.

Example
local stack = Stack(
    "Top",
    "Middle",
    "Bottom"
)
Stack(...)

Parameters

  • ...

Returns - Stack

Types

Stack