PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/iterator/example3.e

http://github.com/tybor/Liberty
Specman e | 41 lines | 32 code | 5 blank | 4 comment | 0 complexity | 3f5de4dab857748a9a9734aad69d616f MD5 | raw file
 1class EXAMPLE3
 2   --
 3   -- To add a loop variant for any kind of ITERATOR (for loop variant
 4   -- fans only ;-).
 5   --
 6
 7create {ANY}
 8   make
 9
10feature {}
11   iterator: ITERATOR_WITH_VARIANT[INTEGER]
12
13   make
14      local
15         simple_iterator: ITERATOR[INTEGER]
16      do
17         create {ITERATOR_ON_RANDOM_GENERATOR} simple_iterator.make(10)
18         create iterator.make(simple_iterator)
19         io.put_string("First traversal :%N")
20         traverse
21         io.put_string("Second traversal :%N")
22         traverse
23      end
24
25   traverse
26      do
27         from
28            iterator.start
29         variant
30            iterator.variant_value
31         until
32            iterator.is_off
33         loop
34            io.put_integer(iterator.item)
35            io.put_character(' ')
36            iterator.next
37         end
38         io.put_new_line
39      end
40
41end -- class EXAMPLE3