Libraries.Containers.Support.ListIterator Documentation

The ListIterator class for Lists, enables iteration for the list data structure.

Example Code

use Libraries.Containers.List
use Libraries.Containers.Blueprints.ListIterator

class Main
action main
    List<integer> myList
    ListIterator<List<integer>> listIt = myList: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)

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.List
use Libraries.Containers.Iterator
List<integer> myList
Iterator<integer> listIterator = myList:GetIterator()
integer item = listIterator: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()

GetList()

This action gets the list that the iterator has.

Return

Libraries.Containers.List: The list.

Example

use Libraries.Containers.List
use Libraries.Containers.Support.ListIterator
ListIterator<List<integer>> listIterator 
listIterator:GetList()

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.List
use Libraries.Containers.Iterator
List<integer> myList
Iterator<integer> listIterator = myList:GetIterator()

if listIterator:HasNext()
    listIterator: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.List
use Libraries.Containers.Iterator
List<integer> myList
Iterator<integer> listIterator = myList:GetIterator()
integer item = listIterator:Next()

Rewind()

This action starts the iteration over from the beginning.

Example

use Libraries.Containers.List
use Libraries.Containers.Iterator
List<integer> myList
Iterator<integer> listIterator = myList:GetIterator()

if listIterator:HasNext()
    listIterator:Next()
end

listIterator:Rewind()

Set(Type t)

This action sets the value of the current point in the list. Generally, this action should not be used outside of the Libraries.Containers.List class.

Parameters

Set(Libraries.Containers.List<Type> newList, Libraries.Containers.Support.ListNode<Type> newHead, Libraries.Containers.Support.ListNode<Type> newTail)

This action sets the list parameters up for the iterator.

Parameters

Example

use Libraries.Containers.List
use Libraries.Containers.Support.ListIterator
use Libraries.Containers.Support.ListNode
List<integer> myList
ListNode<integer> head
ListNode<integer> tail
ListIterator<List<integer>> listIterator
listIterator:Set(myList, head, tail)