ObjectType:iterator

From Lavish Software Wiki
Jump to navigation Jump to search

Overview

Object Type Vitals
iterator
Defined By LavishScript
Inherits none
Reduces To NULL
Variable Object Type iterator
Uses Sub-Types no
C/C++ Type LSIterator *

An iterator is a special type of object that allows iteration of the contents of another object, or other type of list associated with some object.

The available members and methods for an iterator object depend on the aforementioned contents or list being iterated. For example, a set has only keys, but a collection has keys and values.

Members

  •  ? Target: The iteration target object (such as a set or collection being iterated). The object type will be the original object type of the object
  •  ? Key: The current key in the iteration. The object type depends on the data being iterated.
  •  ? Value: The current value in the iteration. The object type depends on the data being iterated.
  • bool IsValid: Determines if the iterator is valid, pointing to a valid iteration target and key/value
  • bool Reversible: TRUE if the list being iterated also goes backwards, thus making the Previous method valid
  • bool Constant: TRUE if the list will not allow you to set object values (i.e. the values are constant)
  • bool RandomAccess: TRUE if the list allows random access (the iterator:Jump method)

Methods

  • First: Sets the iterator position to the first element
  • Last: Sets the iterator position to the last element
  • Next: Sets the iterator position to the next element (continues iteration forward)
  • Previous: Sets the iterator position to the previous element (continues iteration backward)
  • SetValue[...]: Sets the value at the current iterator position
  • Jump[...]: Jumps to a given element

See Also

LavishScript Object Types