/src/lib/iterator/internal/iterator_on_set.e

http://github.com/tybor/Liberty · Specman e · 79 lines · 42 code · 12 blank · 25 comment · 0 complexity · f50a0c28f68bc605b203a4667066774c MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class ITERATOR_ON_SET[E_]
  5. -- Please do not use this class directly. Look at `ITERATOR'.
  6. inherit
  7. ITERATOR[E_]
  8. create {ANY}
  9. make
  10. feature {}
  11. set: SET[E_]
  12. -- The one to be traversed.
  13. item_index: INTEGER
  14. feature {ANY}
  15. make (d: SET[E_])
  16. require
  17. d /= Void
  18. do
  19. set := d
  20. start
  21. ensure
  22. set = d
  23. end
  24. start
  25. do
  26. item_index := 1
  27. generation := iterable_generation
  28. end
  29. is_off: BOOLEAN
  30. do
  31. Result := item_index > set.count
  32. end
  33. item: E_
  34. do
  35. Result := set.item(item_index)
  36. end
  37. next
  38. do
  39. item_index := item_index + 1
  40. end
  41. feature {ANY}
  42. iterable_generation: INTEGER
  43. do
  44. Result := set.generation
  45. end
  46. generation: INTEGER
  47. end -- class ITERATOR_ON_SET
  48. --
  49. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  50. --
  51. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  52. -- of this software and associated documentation files (the "Software"), to deal
  53. -- in the Software without restriction, including without limitation the rights
  54. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  55. -- copies of the Software, and to permit persons to whom the Software is
  56. -- furnished to do so, subject to the following conditions:
  57. --
  58. -- The above copyright notice and this permission notice shall be included in
  59. -- all copies or substantial portions of the Software.
  60. --
  61. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  64. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  65. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  66. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  67. -- THE SOFTWARE.