PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/tutorial/backtracking/logigram/item_var.e

http://github.com/tybor/Liberty
Specman e | 81 lines | 52 code | 11 blank | 18 comment | 2 complexity | a27222df5e20d36ac0dfdf89d946f0ae MD5 | raw file
 1-- See the Copyright notice at the end of this file.
 2--
 3class ITEM_VAR
 4
 5inherit
 6	ITEM
 7
 8creation {ANY}
 9	make
10
11feature {ANY}
12	item: ITEM
13
14	index: INTEGER is
15		do
16			Result := item.index
17		end
18
19	to_integer: INTEGER is
20		do
21			Result := item.to_integer
22		end
23
24	make (the_group: like group; the_name: like name) is
25		do
26			group := the_group
27			name := the_name
28		end
29
30	start is
31		do
32			if group.item_count = 0 then
33				item := Void
34			else
35				goto_index(0)
36			end
37		end
38
39	is_off: BOOLEAN is
40		do
41			Result := item = Void
42		ensure
43			Result = (item = Void)
44		end
45
46	next is
47		do
48			if item.index + 1 < group.item_count then
49				goto_index(item.index + 1)
50			else
51				item := Void
52			end
53		end
54
55	goto_index (idx: INTEGER) is
56		require
57			idx.in_range(0, group.item_count - 1)
58		do
59			group.goto_index(idx)
60			item := group.item
61		ensure
62			not is_off
63		end
64
65end -- class ITEM_VAR
66--
67-- ------------------------------------------------------------------------------------------------------------------------------
68-- Copyright notice below. Please read.
69--
70-- This file is free software, which comes along with SmartEiffel. This software is distributed in the hope that it will be
71-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
72-- You can modify it as you want, provided this footer is kept unaltered, and a notification of the changes is added.
73-- You are allowed to redistribute it and sell it, alone or as a part of another product.
74--
75-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
76-- Copyright(C) 2003-2005: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
77--
78-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
79--
80-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
81-- ------------------------------------------------------------------------------------------------------------------------------