Difference between revisions of "ObjectType:queue"
Jump to navigation
Jump to search
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{ObjectType-Vitals|queue|[[LavishScript]]|[[ObjectType:objectcontainer|objectcontainer]]|NULL|queue|yes|LSQueue *}} | ||
== Overview == | == Overview == | ||
− | |||
A '''queue''' is a first-in first-out (as if waiting in a line) list of objects. | A '''queue''' is a first-in first-out (as if waiting in a line) list of objects. | ||
== Members == | == Members == | ||
− | |||
*sub-type '''Peek''': Retrieves the first object in the queue (first in line) | *sub-type '''Peek''': Retrieves the first object in the queue (first in line) | ||
== Methods == | == Methods == | ||
− | * | + | *'''Queue['''...''']''': Adds an object to the queue, passing any parameters to the initialization for the given object type |
− | + | *'''Dequeue''': Removes the first object in the queue | |
− | *Dequeue: Removes the first object in the queue | + | *'''Clear''': Clears all objects in the queue |
− | * | ||
== Declaring queue Variables == | == Declaring queue Variables == | ||
Line 43: | Line 41: | ||
MyQueue:Queue[15] | MyQueue:Queue[15] | ||
MyQueue:Queue[25] | MyQueue:Queue[25] | ||
− | echo \${MyQueue.Peek} should be 15: | + | echo \${MyQueue.Peek} should be 15: ${MyQueue.Peek} |
MyQueue:Dequeue | MyQueue:Dequeue | ||
/* Only 25 is now in the queue */ | /* Only 25 is now in the queue */ | ||
− | echo \${MyQueue.Peek} should be 25: | + | echo \${MyQueue.Peek} should be 25: ${MyQueue.Peek} |
== See Also == | == See Also == | ||
− | + | {{LavishScript:ObjectType}} | |
− | |||
− |
Latest revision as of 16:14, 8 July 2018
queue | |
Defined By | LavishScript |
Inherits | objectcontainer |
Reduces To | NULL |
Variable Object Type | queue |
Uses Sub-Types | yes |
C/C++ Type | LSQueue * |
Contents
Overview
A queue is a first-in first-out (as if waiting in a line) list of objects.
Members
- sub-type Peek: Retrieves the first object in the queue (first in line)
Methods
- Queue[...]: Adds an object to the queue, passing any parameters to the initialization for the given object type
- Dequeue: Removes the first object in the queue
- Clear: Clears all objects in the queue
Declaring queue Variables
Queue objects require a sub-type -- an object type to be a queue of. Append the sub-type to the word queue, with a colon separating the words. It is possible to have sub-subtypes (such as queue:queue:int for a queue of queues of ints).
Example 1
Declaring a queue of "int"
variable queue:int MyQueue
Adding items to a queue
To add an item to a queue, use the Queue method, as demonstrated in this example
Example 1
variable queue:int MyQueue MyQueue:Queue[15] MyQueue:Queue[25]
Removing items from a queue
Items are removed in the order queued -- the first item queued is the first that will be removed. To remove an item, use the Dequeue method, as demonstrated in this example
Example 1
variable queue:int MyQueue MyQueue:Queue[15] MyQueue:Queue[25] MyQueue:Dequeue /* Only 25 is now in the queue */
Viewing the queue
To access the first object in the queue (e.g. the first person in line), use the Peek member, as demonstrated in this example
Example 1
variable queue:int MyQueue MyQueue:Queue[15] MyQueue:Queue[25] echo \${MyQueue.Peek} should be 15: ${MyQueue.Peek} MyQueue:Dequeue /* Only 25 is now in the queue */ echo \${MyQueue.Peek} should be 25: ${MyQueue.Peek}
See Also
LavishScript Object Types
- Text
- string - mutablestring - unistring
- Numbers
- byte - float - float64 - int - uint - int64
- Boolean (TRUE/FALSE)
- bool
- Pointers
- boolptr - byteptr - floatptr - float64ptr - intptr - uintptr - int64ptr - rgbptr - stringptr
- Containers
- objectcontainer - array - index - collection - queue - stack - set - variablescope
- JSON
- jsonobject - jsonarray - jsonvaluecontainer - jsonvalue
- Iteration
- iterator - jsoniterator
- Date/Time
- time
- File Handling
- filepath - file - filelist - filelistentry
- Tasks
- lavishmachine - Accessed via the Top-Level Object LMAC
- task - tasklibrary - taskmanager - tasktype - taskpulseargs - elmactaskstate