An iterator that yield each item in order

Introduced properties

Redefined properties

redef type SELF: OrderedIter[E]

functional $ OrderedIter :: SELF

Type of this instance, automatically specialized in every class
redef fun finish

functional $ OrderedIter :: finish

Post-iteration hook.
redef init init

functional $ OrderedIter :: init

redef fun is_ok: Bool

functional $ OrderedIter :: is_ok

Is there a current item ?
redef fun item: E

functional $ OrderedIter :: item

The current item.
redef fun next

functional $ OrderedIter :: next

Jump to the next item.
redef fun to_a: Array[E]

functional $ OrderedIter :: to_a

Interate on self and build an array

All properties

type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun f=(f: Fun1[E, Comparable])

functional :: OrderedIter :: f=

fun finish

core :: Iterator :: finish

Post-iteration hook.
init init

core :: Object :: init

abstract fun is_ok: Bool

core :: Iterator :: is_ok

Is there a current item ?
abstract fun item: E

core :: Iterator :: item

The current item.
abstract fun next

core :: Iterator :: next

Jump to the next item.
fun to_a: Array[E]

core :: Iterator :: to_a

Interate on self and build an array
package_diagram functional::OrderedIter OrderedIter

Ancestors

interface Iterator[E: nullable Object]

core :: Iterator

Iterators generate a series of elements, one at a time.
interface Object

core :: Object

The root of the class hierarchy.

Class definitions

functional $ OrderedIter
# An iterator that yield each item in order
class OrderedIter[E]
        super FunIter[E,E]
        var f: Fun1[E, Comparable]

        private var sorted_iter: Iterator[E] is noinit
        private var sorted_arr: Array[E] is noinit

        redef init
        do
                sorted_arr = my_iter.to_a
                sorted_arr.sort_with(f)
                sorted_iter = sorted_arr.iterator
        end

        redef fun next
        do
                sorted_iter.next
        end

        redef fun item
        do
                return sorted_iter.item
        end

        redef fun is_ok
        do
                return sorted_iter.is_ok
        end

        redef fun finish
        do
                sorted_iter.finish
        end

        redef fun to_a
        do
                return sorted_arr
        end
end
lib/functional/iter_extras.nit:352,1--391,3