@head @module std @title Interfaces
The std module defines several interfaces. They are described in this section. Note that a class may implement multiple interfaces.
An object that implements Sequence can be used as a read-only
sequence. The interface includes the following operations:
@fun length() as Int
@desc Return the length of the sequence.
@end
@op sequence[n] @optype{Sequence @ref{Array} and @ref{Str} implement Sequence. Note that
Array objects are mutable.
Iterable objects provide the iterator method:
@fun iterator() as Iterator @ref{Str}, @ref{Range}, @ref{Array}, @ref{Map}, @ref{Set} and @ref{Stream}
objects implement Iterable.
An object that supports the Iterator interface performs an
iteration over the items of a composite object. It provides these methods:
@fun hasNext() as Boolean
@desc Return a boolean indicating whether there are additional objects in the
iteration.
@end
@fun next() as T
@desc Return the next object in the iteration. The iterator interface
does not specify the order in which objects are returned, but many
iterable types, such as @ref{Array}, guarantee a specific iteration
order.
@end
Interface Iterable<T>
@class-hidden Iterable
Interface Iterator<T>
@class-hidden Iterator
Interface Comparable<T>
@class-hidden Comparable
@op o < x @optype{ComparableInterface Addable<OT, RT>
@class-hidden Addable
@op o + x @optype{MultipliableInterface Multipliable<OT, RT>
@class-hidden Multipliable
@op o * x @optype{Multipliable