The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
Optional
elements: T[]The elements
parameter is an optional array of elements of type T
. If provided, it
will be used to initialize the _nodes
property of the class. If not provided, the _nodes
property will be
initialized as an empty array.
Protected
_nodesProtected
_offsetThe offer function adds an element to the end of the queue and returns the updated queue.Adds an element at the back of the queue.
The element
parameter represents the element that you want to add to the queue.
The offer
method is returning a Queue<T>
object.
The peek
function returns the first element of the array _nodes
if it exists, otherwise it returns null
.
The peek()
method returns the first element of the data structure, represented by the _nodes
array at
the _offset
index. If the data structure is empty (size is 0), it returns null
.
Static
fromThe function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
The "elements" parameter is an array of elements of type T.
The method is returning a new instance of the Queue class, initialized with the elements from the input array.
Generated using TypeDoc
License
MIT
Copyright
2030 Tyler Zeng zrwusa@gmail.com