var i: Iterator[Int]
i = new NullSkipper[Int]([null, 1, null, 2, null: nullable Int].iterator)
assert i.to_a == [1, 2]
i = new NullSkipper[Int]([1, null, 2, 3: nullable Int].iterator)
assert i.to_a == [1, 2, 3]
pipeline :: NullSkipper :: defaultinit
pipeline $ NullSkipper :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
pipeline :: NullSkipper :: defaultinit
core :: Object :: 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).
# Wraps an iterator to skip nulls.
#
# ~~~nit
# var i: Iterator[Int]
#
# i = new NullSkipper[Int]([null, 1, null, 2, null: nullable Int].iterator)
# assert i.to_a == [1, 2]
#
# i = new NullSkipper[Int]([1, null, 2, 3: nullable Int].iterator)
# assert i.to_a == [1, 2, 3]
# ~~~
class NullSkipper[E: Object]
super Iterator[E]
# The inner iterator.
var inner: Iterator[nullable E]
redef fun finish do inner.finish
redef fun is_ok do
skip_nulls
return inner.is_ok
end
redef fun item do
skip_nulls
return inner.item.as(E)
end
redef fun next do
inner.next
skip_nulls
end
private fun skip_nulls do
while inner.is_ok and inner.item == null do inner.next
end
end
lib/pipeline/pipeline.nit:253,1--290,3