/tutorial/iterator/example2.e

http://github.com/tybor/Liberty · Specman e · 35 lines · 27 code · 5 blank · 3 comment · 0 complexity · c8a6bafe4f84865080ece6355d7ef606 MD5 · raw file

  1. class EXAMPLE2
  2. --
  3. -- Using an ITERATOR to traverse a random collection of INTEGER.
  4. --
  5. create {ANY}
  6. make
  7. feature {}
  8. iterator: ITERATOR_ON_RANDOM_GENERATOR
  9. make
  10. do
  11. create iterator.make(10)
  12. io.put_string("First traversal :%N")
  13. traverse
  14. io.put_string("Second traversal :%N")
  15. traverse
  16. end
  17. traverse
  18. do
  19. from
  20. iterator.start
  21. until
  22. iterator.is_off
  23. loop
  24. io.put_integer(iterator.item)
  25. io.put_character(' ')
  26. iterator.next
  27. end
  28. io.put_new_line
  29. end
  30. end -- class EXAMPLE2