/[eiffelstudio]/FreeELKS/trunk/library/kernel/boolean_ref.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/kernel/boolean_ref.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91424 - (show annotations)
Tue Oct 26 18:39:32 2004 UTC (15 years, 3 months ago) by manus_eiffel
File size: 4369 byte(s)
Initial revision

1 indexing
2
3 description:
4 "References to objects containing a boolean value"
5
6 status: "See notice at end of class"
7 date: "$Date$"
8 revision: "$Revision$"
9
10 class BOOLEAN_REF inherit
11
12 HASHABLE
13 redefine
14 is_hashable, out
15 end
16
17 feature -- Access
18
19 item: BOOLEAN
20 -- Boolean value
21
22 hash_code: INTEGER is
23 -- Hash code value
24 do
25 Result := 1
26 end
27
28 feature -- Status report
29
30 is_hashable: BOOLEAN is
31 -- May current object be hashed?
32 -- (True if it is not its type's default.)
33 do
34 Result := item
35 end
36
37 feature {NONE} -- Initialization
38
39 make_from_reference (v: BOOLEAN_REF) is
40 -- Initialize `Current' with `v.item'.
41 require
42 v_not_void: v /= Void
43 do
44 item := v.item
45 ensure
46 item_set: item = v.item
47 end
48
49 feature -- Conversion
50
51 to_reference: BOOLEAN_REF is
52 -- Associated reference of Current
53 do
54 create Result
55 Result.set_item (item)
56 ensure
57 to_reference_not_void: Result /= Void
58 end
59
60 to_integer: INTEGER is
61 -- 1 if `True'
62 -- 0 if `False'
63 do
64 if item then
65 Result := 1
66 end
67 ensure
68 zero_or_one: Result = 0 or Result = 1
69 item_implies_one: item implies Result = 1
70 end
71
72 feature -- Element change
73
74 set_item (b: BOOLEAN) is
75 -- Make `b' the `item' value.
76 do
77 item := b
78 end
79
80 feature -- Basic operations
81
82 infix "and" (other: like Current): BOOLEAN is
83 -- Boolean conjunction with `other'
84 require
85 other_exists: other /= Void
86 do
87 Result := item and other.item
88 ensure
89 de_morgan: Result = not (not Current or not other)
90 commutative: Result = (other and Current)
91 consistent_with_semi_strict: Result implies (Current and then other)
92 end
93
94 infix "and then" (other: like Current): BOOLEAN is
95 -- Boolean semi-strict conjunction with `other'
96 require
97 other_exists: other /= Void
98 do
99 Result := item and then other.item
100 ensure
101 de_morgan: Result = not (not Current or else not other)
102 end
103
104 infix "implies" (other: like Current): BOOLEAN is
105 -- Boolean implication of `other'
106 -- (semi-strict)
107 require
108 other_exists: other /= Void
109 do
110 Result := item implies other.item
111 ensure
112 definition: Result = (not Current or else other)
113 end
114
115 prefix "not": like Current is
116 -- Negation
117 do
118 create Result
119 Result.set_item (not item)
120 end
121
122 infix "or" (other: like Current): BOOLEAN is
123 -- Boolean disjunction with `other'
124 require
125 other_exists: other /= Void
126 do
127 Result := item or other.item
128 ensure
129 de_morgan: Result = not (not Current and not other)
130 commutative: Result = (other or Current)
131 consistent_with_semi_strict: Result implies (Current or else other)
132 end
133
134 infix "or else" (other: like Current): BOOLEAN is
135 -- Boolean semi-strict disjunction with `other'
136 require
137 other_exists: other /= Void
138 do
139 Result := item or else other.item
140 ensure
141 de_morgan: Result = not (not Current and then not other)
142 end
143
144 infix "xor" (other: like Current): BOOLEAN is
145 -- Boolean exclusive or with `other'
146 require
147 other_exists: other /= Void
148 do
149 Result := item xor other.item
150 ensure
151 definition: Result = ((Current or other) and not (Current and other))
152 end
153
154 feature -- Output
155
156 out: STRING is
157 -- Printable representation of boolean
158 do
159 if item then
160 Result := "True"
161 else
162 Result := "False"
163 end
164 end
165
166 invariant
167
168 involutive_negation: is_equal (not (not Current))
169 non_contradiction: not (Current and (not Current))
170 completeness: Current or else (not Current)
171
172 indexing
173
174 library: "[
175 EiffelBase: Library of reusable components for Eiffel.
176 ]"
177
178 status: "[
179 Copyright 1986-2001 Interactive Software Engineering (ISE).
180 For ISE customers the original versions are an ISE product
181 covered by the ISE Eiffel license and support agreements.
182 ]"
183
184 license: "[
185 EiffelBase may now be used by anyone as FREE SOFTWARE to
186 develop any product, public-domain or commercial, without
187 payment to ISE, under the terms of the ISE Free Eiffel Library
188 License (IFELL) at http://eiffel.com/products/base/license.html.
189 ]"
190
191 source: "[
192 Interactive Software Engineering Inc.
193 ISE Building
194 360 Storke Road, Goleta, CA 93117 USA
195 Telephone 805-685-1006, Fax 805-685-6869
196 Electronic mail <info@eiffel.com>
197 Customer support http://support.eiffel.com
198 ]"
199
200 info: "[
201 For latest info see award-winning pages: http://eiffel.com
202 ]"
203
204 end -- class BOOLEAN_REF
205
206
207

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23