This example illustrates how to use LVOOP to create a priority queue. A priority queue is a queue that automatically sorts the elements according to their assigned priority. If a high priority element is on the queue, it will be dequeued before a lower priority element, regardless of which element was actually placed on the queue first. PriorityQueues are a generally useful component that can be applicable to any game or test application.
Note: This simplified example is intended to show the core functionality of the PriorityQueue class. As such, only four methods are given (Create, Enqueue, Dequeue, and Destroy) and options such as queue size and named queues are not implemented. The Dequeue method has a disabled case showing how to implement code that allows the user to input a timeout value. Methods to implement the other queue primitives along with all their available options are easily created. They are omitted here for clarity.
When fully implemented this class duplicates the behavior of the queue primitives with the added feature of having the ability to set priority levels to each queue element. The implementation uses an array of queue refnums--one for each priority level. Encapsulating the array in a class allows the user to treat the PriorityQueue just like a normal queue.
There are two usage examples included. Example 1 demonstrates the priority queue's basic capability of sorting queue elements. Example 2 illustrates how a priority queue could be used in an application.
Not applicable. Download the project and open it in Labview 2009 or later.