local Queue = {}
-- Create a new queue instance
function New(data : {}?, max_capacity : number?)
return {
_DATA = data or {},
_MAX_CAPACITY = max_capacity or nil,
Pop = Pop,
Push = Push,
Peek = Peek,
Size = Size,
IsEmpty = IsEmpty,
IsFull = IsFull,
Clear = Clear,
GetIterator = GetIterator,
}
end
-- Helper function to access data
local function data(Q)
return Q._DATA
end
-- Helper function to access max capacity
local function max_capacity(Q)
return Q._MAX_CAPACITY
end
-- Get the current size of the queue
function Size(Q) : number
return #data(Q)
end
-- Remove and return the element at the front of the queue
function Pop(Q) : any?
return table.remove(data(Q), 1) -- FIFO behavior
end
-- Add an element to the back of the queue
function Push(Q, v) : boolean
if max_capacity(Q) and Size(Q) >= max_capacity(Q) then
return false -- Queue is full
end
table.insert(data(Q), v)
return true
end
-- View the element at the front without removing it
function Peek(Q) : any?
return data(Q)[1] -- FIFO behavior
end
-- Check if the queue is empty
function IsEmpty(Q) : boolean
return Size(Q) == 0
end
-- Check if the queue is full
function IsFull(Q) : boolean
return max_capacity(Q) and Size(Q) >= max_capacity(Q)
end
-- Clear the queue
function Clear(Q)
Q._DATA = {}
end
-- Get an iterator for the queue
function GetIterator(Q)
local index = 0
local size = Size(Q)
return function()
index = index + 1
if index <= size then
return Q._DATA[index]
end
end
end
return New
Removing certain elements from the code fixes it. For example, removing : boolean from IsFull. Also, moving IsFull to a different position in the script also fixes it, without needing to remove : boolean
I have all beta-features enabled besides the following:
- Next Gen Explorer
- Next Gen Studio Preview
- Avatar Auto-Setup Beta
Expected behavior
It shouldn’t be orange; there’s no issue.