Difference between revisions of "ObjectType:queue"
Jump to navigation
Jump to search
m (→Example 1) |
|||
Line 1: | Line 1: | ||
== Overview == | == Overview == | ||
− | {{ObjectType-Vitals|queue|[[LavishScript]]| | + | {{ObjectType-Vitals|queue|[[LavishScript]]|[[ObjectType:objectcollection|objectcollection]]|NULL|queue|yes|LSQueue *}} |
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 | *'''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 | ||
− | |||
== Declaring queue Variables == | == Declaring queue Variables == |
Revision as of 15:31, 7 May 2006
Contents
Overview
queue | |
Defined By | LavishScript |
Inherits | objectcollection |
Reduces To | NULL |
Variable Object Type | queue |
Uses Sub-Types | yes |
C/C++ Type | LSQueue * |
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
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}