PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/src/lib/iterator/internal/iterator_on_string.e

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