/src/lib/numeric/internal/integer_range_iterator.e

http://github.com/tybor/Liberty · Specman e · 81 lines · 46 code · 12 blank · 23 comment · 0 complexity · 72d1b22884c60587418f18c7388c9421 MD5 · raw file

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