A CollectionStream can be used as an external iterator for each interger-indexed collection. The state of the iterator is stored in instance variable @pos.
A CollectionStream for an array is created by the method Array#create_stream.
Creates a new CollectionStream for the indexable sequence seq.
# File lib/stream.rb, line 146 def initialize(seq) @seq = seq set_to_begin end
# File lib/stream.rb, line 152 def at_beginning?; @pos < 0; end
# File lib/stream.rb, line 151 def at_end?; @pos + 1 >= @seq.size; end
# File lib/stream.rb, line 161 def basic_backward; r = @seq[@pos]; @pos -= 1; r; end
# File lib/stream.rb, line 160 def basic_forward; @pos += 1; @seq[@pos]; end
basic_current and basic_peek can be implemented more efficiently than in superclass
# File lib/stream.rb, line 167 def basic_current; @seq[@pos]; end
Generated with the Darkfish Rdoc Generator 2.