API/Queue

Enumerable.prototype:ToQueue()

Make a new Queue filled with the contents of the current Enumerable

Return value

a Queue


Queue.FromArguments(...)

Construct and return a new queue based on the arguments provided

Parameters

...
a tuple of arguments to fill the queue with

Return value

a Queue

Usage

local queue = Queue.FromArguments()
local queue = Queue.FromArguments(1, 2, 3)
local queue = Queue.FromArguments(nil, nil, 5)


Queue.New(sequence)

Construct and return a new queue

Parameters

sequence
optional: The sequence to fill the queue with

Return value

a Queue

Usage

local queue = Queue.New()
local queue = Queue.New({ 1, 2, 3 })
local queue = Queue.New(Enumerable.RangeTo(1, 10))


Queue.prototype:Clear()

Clear all elements from the Queue

Usage

queue:Clear()


Queue.prototype:Clone()

Make a shallow clone of the Queue.

Usage

local other = queue:Clone()


Queue.prototype:Dequeue()

Removes and returns the object at the beginning of the Queue.
This will error if the Queue contains no elements.

Return value

The item removed.

Usage

local removed = queue:Dequeue()


Queue.prototype:Enqueue(item)

Add an element to end of the Queue

Parameters

item
the element to add

Usage

queue:Enqueue(5)
queue:Enqueue(nil)


Queue.prototype:GetEnumerator()

Return an Enumerator for the current Queue

Return value

an Enumerator


Queue.prototype:IsReadOnly()

Return whether the Queue is read-only, always returns false.

Return value

a boolean

Usage

local read_only = stack:IsReadOnly()


Queue.prototype:Peek()

Returns the object at the beginning of the Queue without removing it.
This will error if the Queue contains no elements.

Return value

The item at the beginning.

Usage

local item = queue:Peek()


Queue.prototype:SetContract(contract)

Set a contract that will be verified against any existing elements and any added elements or changed values.
This is handy for if you want to verify that all values are strings or something like that. This will call :VerifyContract()

Parameters

contract
a function that is passed the element and should return whether the element is valid.

Usage

queue:SetContract(function(v) return type(v) == "string" end)


Queue.prototype:VerifyContract()

Verify that the contract for this Queue is valid for all elements in the Queue.
If there is no contract, this does nothing.

Usage

queue:VerifyContract()



Comments

Posts Quoted:
Reply
Clear All Quotes