Libraries.Containers.Support.ArrayIterator Documentation

The ArrayIterator class for Arrays, enables iteration for the array data structure. Generally, there is no need to use this class directly, as most users will only need an instance of the parent, the Iterator class.

Example Code

use Libraries.Containers.Blueprints.ArrayIterator

class Main
action main
    Array<integer> myArray
    ArrayIterator<Array<integer>> arrayIt = myArray:GetIterator()
end
end

Inherits from: Libraries.Language.Object, Libraries.Containers.Iterator

Actions Documentation

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)

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)

GetArray()

This action gets the array that the iterator has.

Return

Libraries.Containers.Array: The array.

Example

use Libraries.Containers.Array
use Libraries.Containers.Iterator
use Libraries.Containers.Support.ArrayIterator

Array<integer> myArray
ArrayIterator<integer> arrayIterator = cast(ArrayIterator, myArray:GetIterator())
Array<integer> array = arrayIterator:GetArray()

GetCurrent()

This action gets the current item in the iteration without continuing the iteration.

Return

Libraries.Language.Object: The current item in the iteration.

Example

use Libraries.Containers.Array
use Libraries.Containers.Iterator
Array<integer> myArray
Iterator<integer> arrayIterator = myArray:GetIterator()
integer item = arrayIterator:GetCurrent()

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

HasNext()

This action determines if there is a next item in the iteration. It returns true if there is a next and false if there is not.

Return

boolean: True if there is a next in the iteration and false if there is not.

Example

use Libraries.Containers.Array
use Libraries.Containers.Iterator
Array<Array<integer>> myArray
Iterator<Array<integer>> arrayIterator = myArray:GetIterator()

if arrayIterator:HasNext()
    arrayIterator:Next()
end

Next()

This action get the next item in the iteration.

Return

Libraries.Language.Object: The next item in the iteration.

Example

use Libraries.Containers.Array
use Libraries.Containers.Iterator
Array<integer> myArray
Iterator<integer> arrayIterator = myArray:GetIterator()
integer item = arrayIterator:Next()

Rewind()

This action starts the iteration over from the beginning.

Example

use Libraries.Containers.Array
use Libraries.Containers.Iterator
Array<Array<integer>> myArray
Iterator<Array<integer>> arrayIterator = myArray:GetIterator()

if arrayIterator:HasNext()
    arrayIterator:Next()
end

arrayIterator:Rewind()

Set(Libraries.Containers.Array<Type> newArray)

This action sets the array parameters up for the iterator.

Parameters

Example

use Libraries.Containers.Array
use Libraries.Containers.Iterator
use Libraries.Containers.Support.ArrayIterator

Array<integer> myArray
ArrayIterator<integer> iterator
iterator:Set(myArray)