PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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