- Alvin Lee
PrimitiveQueue<>
IPrimitiveQueue<>
PrimitiveQueue<> Methods
PrimitiveQueue() | Constructor for the PrimitiveQueue<> class |
Size() | Returns number of items in the queue |
AddItem() | Adds an item to the end of the list (FIFO) or start of the list (LIFO) and trigger a receive event |
AddExpressItem() | Inserts an item at the beginning of the queue and trigger a receive event |
GetItem() | Gets next item from the queue and removes it |
PeekItem() | Gets next item from the queue without removing it |
PeekItem() | Gets item from the queue at specified one based position without removing it |
GotoTop() | Moves internal "pointer" to top of list |
GotoBottom() | Moves internal "pointer" to bottom of list |
GetCurrentItem() | Gets "current" object in collection and move pointer position |
IsCurrentValid() | Returns true if the "pointer" currently points at a valid position |
Clear() | Clears all items from the queue |
QueueType() | Returns the queue type as QueueType.LIFO or QueueType.FIFO |
AddQueueReceiveHandler() | Adds event handler for a "receive" event (AddItem(), AddExpressItem()) using a method reference |
AddQueueReceiveHandler() | Adds event handler for a "receive" event (AddItem(), AddExpressItem()) using an IQueue reference |
OnQueueReceive() | Event handler for PrimitiveQueueEvent<> processing |
IPrimitiveQueue Methods
OnQueueReceive() | Virtual method to handle PrimitiveQueueEvent<> processing |
Derived Classes
None
See Also
Class Hierarchy, PrimitiveQueueEvent<>, Queue<>, PrimitiveRefQueue<>, ObjectQueue
public method PrimitiveQueue(int Mode = QueueType.FIFO, bool ProcessEvents = false)
Parameters
Mode
Queue type enumeration value (FIFO or LIFO)
ProcessEvents
Add event handling if true
Return Value
None
Description
Constructor for the PrimitiveQueue<> class. The queue mode is specified using one of the two QueueType enumeration values (FIFO - First In First Out, LIFO - Last In First Out) and the "process events" flag can also be specified. If true, the system sets up the default handler for queue receive events (OnQueueReceive()). If false, the event handling is not turned on.
PrimitiveQueue<> Class
public virtual method<int> Size()
Parameters
None
Return Value
Returns size of queue
Description
This method returns the total number of primitive objects currently stored in the queue.
PrimitiveQueue<> Class
public method AddItem(T ObjectValue)
Parameters
ObjectValue
Primitive object value to be added to queue
Return Value
None
Description
This method adds the specified primitive object value to the queue. If it's a FIFO queue, the object is added to the end of the queue. If LIFO, it's added to the beginning of the queue. The storage for the queue is handled internally, and automatically grows the queue if necessary. The user of the class doesn't need to worry about any of the details.
This method will result in a QueueEvent<> if the queue was created with event processing turned on.
PrimitiveQueue<> Class
public method AddExpressItem(T Object)
Parameters
ObjectValue
Primitive object value to be added to queue
Return Value
None
Description
This method adds the specified primitive object value to the queue. Regardless of queue type, this item is placed at the beginning of the queue so that the next "GetItem()" call will return this object.
This method will result in a PrimitiveQueueEvent<> if the queue was created with event processing turned on.
PrimitiveQueue<> Class
public method<T> GetItem()
Parameters
None
Return Value
Primitive object value in first position
Description
This method returns the next primitive object value in the queue and removes the item from the queue. If the queue is empty, a value is returned equivalent to the default value for the data type in question.
PrimitiveQueue<> Class
public method<T> PeekItem()
Parameters
None
Return Value
Primitive object value in first position
Description
This method returns the next primitive object value in the queue and does NOT remove the item from the queue. If the queue is empty, a value is returned equivalent to the default value for the data type in question.
PrimitiveQueue<> Class
public method<T> PeekItem(int Position)
Parameters
Position
One based position
Return Value
Object reference at specified position
Description
This method returns the primitive object value at the specified one based position in the queue. If the position is not valid (less than one or greater than the current size of the queue), or if the queue is empty, a value is returned equivalent to the default value for the data type in question.
PrimitiveQueue<> Class
public virtual method GotoTop()
Parameters
None
Return Value
None
Description
This method moves the internal "pointer" to the top of the list. This will always point at the queue position that corresponds to that position which would be returned using the next GetItem() method call. For FIFO, it will be the first item entered. For LIFO, it will be the last item entered.
The "GetCurrentItem()" method returns the object which is at the current pointer location.
PrimitiveQueue<> Class
public virtual method GotoBottom()
Parameters
None
Return Value
None
Description
This method moves the internal "pointer" to the bottom of the list. This will always point at the queue position that is at the opposite end of the queue from the position which would be returned using the next GetItem() method call. For FIFO, it will be the last item entered. For LIFO, it will be the first item entered.
The "GetCurrentItem()" method returns the object which is at the current pointer location.
PrimitiveQueue<> Class
public virtual method<T> GetCurrentItem(bool Forward = true)
Parameters
None
Return Value
Reference to current item
Description
This method returns the object value at the current "pointer" location within the list.
If the Forward flag is true, the current pointer location is then advanced to the next object in the list. If currently at the last position, the pointer is advanced to a "null" position.
If the forward flag is false, the current pointer is moved to the previous object in the list. If currently at the first position, the pointer is advanced to the "null" position.
If the pointer ends up at the "null" position, the next "GetCurrentItem()" call will return null. The "GotoTop()" or "GotoBottom()" method must be used to reset the pointer to a valid position.
If the collection is empty, this method returns a value equivalent to the default value for the data type in question.
PrimitiveQueue<> Class
public virtual method<bool> IsCurrentValid()
Parameters
None
Return Value
True if current position is valid
Description
Virtual method to return true if the "current" pointer within the queue points at a valid position, and returns false if not. If the queue is empty, or if the end of the queue has been surpassed by making a "GetCurrentItem()" call at the end of the queue, the current "pointer" does not point at a valid position (and GetCurrentItem() returns null), so this method returns false.
PrimitiveQueue<> Class
public virtual method Clear()
Parameters
None
Return Value
None
Description
This method clears all items from the queue.
PrimitiveQueue<> Class
public method<QueueType> QueueType()
Parameters
None
Return Value
QueueType.LIFO or QueueType.FIFO
Description
This method returns the queue type enumeration value (FIFO or LIFO). This setting specifies how the data is retrieved from the queue.
PrimitiveQueue<> Class
public method AddQueueReceiveHandler(PrimitiveQueueHandler<T> Handler, Base ExtraObject = null)
Parameters
Handler
Method reference to be executed when the event occurs
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers a method reference to be executed when an item is added to the queue (if "process events" is turned on for the queue). The 'AddItem()' and 'AddExpressItem()' methods both issue this event. An optional object can also be registered which will be sent to each event handler as it is executed.
As is true with all Aztec event handling, this method can be called by any thread. When the event occurs, each registered event handler is scheduled to execute within the thread that registered it. So an item added to queue in one thread can be handled by event handlers executing in one or more other threads.
The PrimitiveQueueHandler<T> data type represents a method reference specific to a handler for PrimitiveQueueEvent<T>. PrimitiveQueueHandler<T> is defined as follows:
public type<method<PrimitiveQeueEvent<T>,Base>> PrimitiveQueueHandler<T>
Given this definition, the method handler must be defined with the following signature (name can be anything):
public method QueueReceiveMethod(PrimitiveQueueEvent<T> event, Base Extra) { }.
PrimitiveQueue<> Class
public method AddQueueReceiveHandler(IPrimitiveQueue<T> Interface, Base ExtraObject = null)
Parameters
Interface
Reference to an IPrimitiveQueue<> object
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers an IPrimitiveQueue<> interface object to be executed when an item is added to the queue (if "process events" is turned on for the queue). The 'AddItem()' and 'AddExpressItem()' methods both issue this event. An optional object can also be registered which will be sent to each event handler as it is executed.
As is true with all Aztec event handling, this method can be called by any thread. When the event occurs, each registered event handler is scheduled to execute within the thread that registered it. So an item added to queue in one thread can be handled by event handlers executing in one or more other threads.
When an item is added to the queue, the OnQueueReceive() method within the IPrimitiveQueue<> object will be executed.
PrimitiveQueue<> Class
public method virtual OnQueueReceive(PrimitiveQueueEvent<T> QueueEvent, Base ExtraObject)
Parameters
QueueEvent
PrimitiveQueueEvent<> object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This method is the default event handler for PrimitiveQueueEvent<> within the thread. It is invoked internally as a result of an item being added to the thread (if the PrimitiveQueue<> was created with the "process events" flag turned on). The 'AddItem()' and 'AddExpressItem()' methods both issue this event.
This method in turn executes every registered handler with the same argument list which comes in. Both implementations of the PrimitiveQueue<T>.AddQueueReceiveHandler() method register the event handlers which get invoked by this method.
If this method is overridden by a class derived from PrimitiveQueue<T>, it must call this implementation of the method if it needs to execute handlers registered with the PrimitiveQueue<T>.AddQueueReceiveHandler() methods.
PrimitiveQueue<> Class
public method virtual OnQueueReceive(PrimitiveQueueEvent<T> QueueEvent, Base ExtraObject)
Parameters
QueueEvent
PrimitiveQueueEvent<> object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This virtual method is the event handler for PrimitiveQueueEvent<> within the IPrimitiveQueue<> interface class. The method which overrides it is invoked when an item is added to the queue and the interface object is registered with the IPrimitiveQueue<>.AddQueueReceiveHandler() method.
IPrimitiveQueue<> Class