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

Summary

Actions Summary Table

ActionsDescription
Add(Type value)This action adds a value at the end of the queue.
AddToEnd(Type value)This action adds an item to the end of the queue.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns a CompareResult.
Copy()This action copies an object and returns the copy.
Empty()This action empty's the queue, clearing out all of the items contained within it.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetFromFront()This action gets the item at the front of the queue(the item will remain in the queue).
GetHashCode()This action gets the hash code for an object.
GetIterator()This action gets an iterator for the object and returns that iterator.
GetSize()This action retrieves the number of elements or nodes in a queue.
Has(Type value)This action determines if an addable object contains a certain item.
IsEmpty()This action returns a boolean value, true if the container is empty and false if it contains any items.
Remove(Type value)This action removes the first occurrence of an item that is found in the Addable object.
RemoveAll(Type value)This action removes all occurrences of an item from the Addable object.
RemoveFromFront()This action removes the item at the front of the queue.

Actions Documentation

Add(Type value)

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

Example Code

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

Parameters

AddToEnd(Type value)

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

Example Code

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

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

Example Code

use Libraries.Language.Support.CompareResult
        Object o
        Object t
        CompareResult result = o:Compare(t)

Parameters

Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

Copy()

This action copies an object and returns the copy.

Example Code

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

Return

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

Empty()

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

Example Code

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.

Example Code

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

Parameters

Return

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

GetFromFront()

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

Example Code

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

Return

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

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetIterator()

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

Example Code

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()

Return

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

GetSize()

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

Example Code

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

Return

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

Has(Type value)

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

Example Code

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

Parameters

Return

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

IsEmpty()

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

Example Code

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

Return

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

Remove(Type value)

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

Example Code

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

Parameters

Return

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

RemoveAll(Type value)

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

Example Code

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

Parameters

Return

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

RemoveFromFront()

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

Example Code

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

Return

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