Queue

open class Queue<T : ModelElement.QObject> @JvmOverloads constructor(parent: ModelElement, name: String? = null, discipline: Queue.Discipline = Discipline.FIFO) : ModelElement, QueueCIfc<T> , QueueIfc<T> (source)

The Queue class provides the ability to hold entities (QObjects) within the model.

FIFO ensures first-in, first-out behavior. LIFO ensures last-in, last-out behavior. RANKED ensures that each new element is added such that the priority is maintained from the smallest first to the largest priority last using the compareTo method of the QObject. Ties in priority give preference to time of creation, then to order of creation. RANDOM causes the elements to be randomly selected (uniformly).

Parameters

parent

its parent

name

The name of the queue

discipline

The queuing discipline to be followed

queues must hold sub-types of QObject

Inheritors

Constructors

Link copied to clipboard
constructor(parent: ModelElement, name: String? = null, discipline: Queue.Discipline = Discipline.FIFO)

Types

Link copied to clipboard
@Serializable
enum Discipline : Enum<Queue.Discipline>

The method of ordering the queue

Link copied to clipboard
Link copied to clipboard
abstract inner class QueueDiscipline
Link copied to clipboard

ENQUEUED indicates that something was just enqueued DEQUEUED indicates that something was just dequeued

Properties

Link copied to clipboard

The current discipline for the queue

Link copied to clipboard
open override var defaultReportingOption: Boolean

Returns the default reporting option. True means that the response should appear on the default reports

Link copied to clipboard
open override val immutableList: List<T>
Link copied to clipboard

The initial queue discipline. The initial discipline indicates the queue distribution that will be used at the beginning of each replication. Changing the initial discipline during a replication will have no effect until the next replication. WARNING: This will cause replications to have different disciplines and thus invalidate the concept of replications if used during a replication. Use this method only when the simulation is not running.

Link copied to clipboard
override var initialStreamNumber: Int

This property provides a reference to allow random selection from queues. It can only be changed if the model is not running. By default, it is set equal to the model's default random number stream

Link copied to clipboard
open override val isEmpty: Boolean

Returns whether the queue is empty.

Link copied to clipboard
open override val isNotEmpty: Boolean

Returns true if the queue is not empty

Link copied to clipboard
open override val numInQ: TWResponseCIfc

Allows access to number in queue response information

Link copied to clipboard
open override val size: Int

Gets the size (number of elements) of the queue.

Link copied to clipboard
open override var status: Queue.Status

Indicates whether something was just enqueued or dequeued

Link copied to clipboard
open override val timeInQ: ResponseCIfc

Allows access to time in queue response information

Link copied to clipboard
open override var waitTimeStatOption: Boolean

Default option for whether waiting time statistics are collected upon removal of items from the queue

Functions

Link copied to clipboard
open override fun addQueueListener(listener: QueueListenerIfc<T>): Boolean

Adds the supplied listener to this queue

Link copied to clipboard
open override fun clear()

Removes all the elements from this collection

Link copied to clipboard
open operator override fun contains(qObj: T): Boolean

Returns true if this queue contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).

operator fun contains(c: Collection<T>): Boolean

Returns true if this queue contains all the elements in the specified collection WARNING: The collection should contain references to QObject's otherwise it will certainly return false.

Link copied to clipboard
fun countBy(predicate: Predicate<T>): Int
fun countBy(predicate: (T) -> Boolean): Int
Link copied to clipboard
open override fun enqueue(qObject: T)
open fun enqueue(qObject: T, priority: Int = qObject.priority, obj: Any? = qObject.attachedObject)

Places the QObject in the queue, with the specified priority Automatically, updates the number in queue response variable.

Link copied to clipboard
fun filter(predicate: Predicate<T>): List<T>
fun filter(predicate: (T) -> Boolean): List<T>

Finds all the QObjects in the Queue that satisfy the condition and returns a list containing them. The items are not removed from the queue.

Link copied to clipboard
operator fun get(index: Int): T

Returns the QObject at the supplied index in the queue.

Link copied to clipboard
fun indexOf(qObj: T): Int

Returns the index in this queue of the first occurrence of the specified element, or -1 if the queue does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Link copied to clipboard
open operator override fun iterator(): Iterator<T>

Returns an iterator (as specified by Collection ) over the elements in the queue in proper sequence. The elements will be ordered according to the state of the queue given the specified queue discipline.

Link copied to clipboard
fun lastIndexOf(qObj: T): Int

Returns the index in this queue of the last occurrence of the specified element, or -1 if the queue does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Link copied to clipboard

Returns an iterator (as specified by Collection ) over the elements in the queue in proper sequence. The elements will be ordered according to the state of the queue given the specified queue discipline.

Link copied to clipboard
fun peekAt(index: Int): T?

Returns the QObject at the supplied index in the queue.

Link copied to clipboard
fun peekFirst(): T?

Returns the QObject at the front of the queue Depending on the queue discipline this may not be the next QObject

Link copied to clipboard
fun peekLast(): T?

Returns the QObject at the last index in the queue.

Link copied to clipboard
open override fun peekNext(): T?

Returns a reference to the QObject representing the item that is next to be removed from the queue according to the queue discipline that was specified.

Link copied to clipboard
open fun remove(qObj: T, waitStats: Boolean = waitTimeStatOption): Boolean

Removes the first occurrence in the queue of the specified element Automatically collects waiting time statistics and number in queue statistics. If the queue does not contain the element then it is unchanged and false is returned

fun remove(condition: Predicate<T>, waitStats: Boolean = waitTimeStatOption): MutableList<T>
fun remove(predicate: (T) -> Boolean, waitStats: Boolean = waitTimeStatOption): MutableList<T>

Finds and removes all the QObjects in the Queue that satisfy the condition and adds them to the deletedItems collection

fun remove(index: Int, waitStats: Boolean = waitTimeStatOption): T

Removes the element at the specified position in this queue. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Link copied to clipboard
fun removeAll(statFlag: Boolean = waitTimeStatOption): Boolean

Removes from this queue all the elements.

fun removeAll(c: Collection<T>, statFlag: Boolean = waitTimeStatOption): Boolean

Removes from this queue all the elements that are contained in the specified collection The collection should contain references to objects of type QObject that had been enqueued in this queue; otherwise, nothing will be removed.

fun removeAll(c: Iterator<T>, statFlag: Boolean = waitTimeStatOption): Boolean

Removes from this queue all the elements that are presented by iterating through this iterator The iterator should be based on a collection that contains references to objects of type QObject that had been enqueued in this queue; otherwise, nothing will be removed.

Link copied to clipboard
fun removeFirst(): T?

Removes the QObject at the front of the queue Uses remove(int index) where index = 0

Link copied to clipboard
fun removeLast(): T?

Removes the QObject at the last index in the queue. Uses remove(int index) where index is the size of the list - 1

Link copied to clipboard
open override fun removeNext(): T?

Removes the next item from the queue according to the queue discipline that was specified. Returns a reference to the QObject representing the item that was removed

Link copied to clipboard
open override fun removeQueueListener(listener: QueueListenerIfc<T>): Boolean

Removes the supplied listener from this queue