Libraries.Containers.Queue Documentation

The Queue class is a data structure that stores items as if the items were in a line, or "Queue." The first items that go into the Queue are the first items to be removed from the Queue (First In First Out). The Queue class is similar to the List class.

Example Code

use Libraries.Containers.Queue
class Main
action Main
   //make the Queue
   Queue<integer> myQueue
   //add a value
   myQueue:Add(12)
   myQueue:Add(13)
   myQueue:Add(14)
   myQueue:Add(15)
   //remove the first item (12)
   integer value = myQueue:RemoveFromFront()
end
end

Inherits from: Libraries.Language.Object

Actions Documentation

Add(Type value)

This action adds a value at the end of the queue.

Parameters

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:Add(12)

AddToEnd(Type value)

This action adds an item to the end of the queue.

Parameters

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:AddToEnd(12)

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Copy()

This action copies an object and returns the copy.

Return

Libraries.Language.Object: Returns a copy of this object.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
Queue<integer> copyQueue
myQueue:Add(12)
Object o = myQueue:Copy()
copyQueue = cast(Queue<integer>, o)

Empty()

This action empty's the queue, clearing out all of the items contained within it.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:Add(12)
myQueue:Empty() //the item we added is now gone

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetFromFront()

This action gets the item at the front of the queue(the item will remain in the queue).

Return

Libraries.Language.Object: The item at the front of the queue.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:Add(4)
myQueue:Add(13)
myQueue:Add(12)
integer value = myQueue:GetFromFront()

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetIterator()

This action gets an iterator for the object and returns that iterator.

Return

Libraries.Containers.Iterator: Returns the iterator for an object.

Example

use Libraries.Containers.Queue
use Libraries.Containers.Iterator
Queue<integer> myQueue
myQueue:Add(12)
myQueue:Add(13)
myQueue:Add(12)
Iterator<integer> QueueIterator = myQueue:GetIterator()

GetSize()

This action retrieves the number of elements or nodes in a queue.

Return

integer: Returns an integer value representing the size of the queue.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:Add(12)
integer size = myQueue:GetSize()

Has(Type value)

This action determines if an addable object contains a certain item.

Parameters

Return

boolean: Returns true if the item was in the Addable object and false if it was not.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:Add(12)
myQueue:Add(1)
boolean hasItem = myQueue:Has(12)

IsEmpty()

This action returns a boolean value, true if the container is empty and false if it contains any items.

Return

boolean: Returns true when the container is empty and false when it is not.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
if myQueue:IsEmpty()
    output "The Queue is empty."
end

Remove(Type value)

This action removes the first occurrence of an item that is found in the Addable object.

Parameters

Return

boolean: Returns true if the item was removed and false if it was not removed.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:Add(43)
myQueue:Add(13)
myQueue:Add(43)
boolean removed = myQueue:Remove(43)

RemoveAll(Type value)

This action removes all occurrences of an item from the Addable object.

Parameters

Return

boolean: Returns true if the item was removed and false if it was not removed.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:Add(43)
myQueue:Add(13)
myQueue:Add(43)
boolean removed = myQueue:RemoveAll(43)

RemoveFromFront()

This action removes the item at the front of the queue.

Return

Libraries.Language.Object: The item at the front of the queue.

Example

use Libraries.Containers.Queue
Queue<integer> myQueue
myQueue:Add(33)
myQueue:Add(13)
myQueue:Add(43)
integer removed = myQueue:RemoveFromFront()