core :: ListIterator
core $ ListIterator :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
core :: IndexedIterator :: defaultinit
core :: ListIterator :: defaultinit
core :: Iterator :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
Iterator
whose elements are sorted by the function
core :: Object :: output_class_name
Display class name on stdout (debug only).
# This is the iterator class of List
class ListIterator[E]
super IndexedIterator[E]
redef fun item do return _node.as(not null).item
# Set item `e` at self `index`.
fun item=(e: E) do _node.as(not null).item = e
redef fun is_ok do return not _node == null
redef fun next
do
_node = _node.as(not null).next
_index += 1
end
# Build a new iterator for `list`.
init
do
_node = _list._head
end
# The current list
private var list: List[E]
# The current node of the list
private var node: nullable ListNode[E] = null
# The index of the current node
redef var index = 0
# Remove the current item
fun delete
do
_list.remove_node(_node.as(not null))
end
# Insert before the current item
fun insert_before(element: E)
do
_list.insert_before(element, _node.as(not null))
end
end
lib/core/collection/list.nit:269,1--311,3