RAA - iterator/0.6

iterator / 0.6

Short description: bidirectional iterator classes inspired by GoF iterator pattern
Category: Library/Design Patterns
Status: stable
Created: 2003-11-20 13:01:21 GMT
Last update: -
Owner: neoneye (Projects of this owner)
Homepage: http://aeditor.rubyforge.org/iterator/
Download: http://rubyforge.org/frs/?group_id=18&release_id=386
License: Ruby's
Dependency:
None
Description:

About
=====

If Ryby's native iterators (yield+each) ain't flexible enough,
you may want to try using this collection of bidirectional
iterator classes. Building custom iterator classes are simple.
This is a simple implementation of GoF iterator-pattern.



Status
======

The overall design are stable. I don't expect any big changes.

Collection, iterates over an Array or similar containers.
Reverse, decorator which reverses the iterator.
Range, iterate in the range between two iterators.
Concat, concat multiple iterators into one.
Continuation, turn #each_word/#each_byte into an iterator.

Plus some StandardTemplateLibrary inspired methods that operate
on iterators.

#copy
#copy_n
#copy_backward
#fill
#fill_n
#transform
#transform2


License
=======

Ruby's license.



Example
=======

We can virtually concatene two arrays, so that they appear
as they were a single array.

def test_concat_sort
i1 = [5, 3, 1].create_iterator
i2 = [2, 4, 6].create_iterator
iterator = Iterator::Concat.new(i1, i2)
assert_equal((1..6).to_a, iterator.sort)
end

Versions: [0.7 (2004-05-06)] [0.6 (-)]

Edit this project (for project owner)

back to RAA top