-
Notifications
You must be signed in to change notification settings - Fork 3
/
point_interval.e
executable file
·125 lines (100 loc) · 2.31 KB
/
point_interval.e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
note
component: "Eiffel Object Modelling Framework"
description: "Form of INTERVAL [G] that represents point (i.e. 'degenerate') intervals."
keywords: "point interval, degenerate interval"
author: "Thomas Beale <[email protected]>"
support: "http://www.openehr.org/issues/browse/AWB"
copyright: "Copyright (c) 2013- Ocean Informatics Pty Ltd <http://www.oceaninfomatics.com>"
license: "Apache 2.0 License <http://www.apache.org/licenses/LICENSE-2.0.html>"
class POINT_INTERVAL [G -> PART_COMPARABLE]
inherit
INTERVAL [G]
redefine
lower
end
STRING_UTILITIES
export
{NONE} all
undefine
out, is_equal
end
create
make
feature -- Initialization
make (a_value: G)
-- make with both limits set to the same value
do
lower := a_value
ensure
Lower_set: lower = a_value
Upper_set: upper = a_value
lower_included_set: lower_included
upper_included_set: upper_included
Is_point: is_point
end
feature -- Access
lower: G
-- lower limit of interval
upper: G
-- upper limit of interval
do
Result := lower
end
midpoint: G
-- generate midpoint of limits
do
Result := lower
end
feature -- Status report
lower_unbounded: BOOLEAN
-- True if lower limit open, i.e. -infinity
do
Result := False
end
upper_unbounded: BOOLEAN
-- True if upper limit open, i.e. +infinity
do
Result := False
end
lower_included: BOOLEAN
-- True if lower limit point included in interval
do
Result := True
end
upper_included: BOOLEAN
-- True if upper limit point included in interval
do
Result := True
end
is_point: BOOLEAN
-- Is current interval a point (width = 0)?
do
Result := True
end
unbounded: BOOLEAN
-- True if interval is completely open
do
Result := False
end
feature -- Comparison
has (v: G): BOOLEAN
-- Does current interval have `v' between its bounds?
do
Result := lower = v
end
intersects (other: INTERVAL [G]): BOOLEAN
-- True if there is any overlap between intervals represented by Current and other
do
Result := other.has (lower)
end
contains (other: like Current): BOOLEAN
-- Does current interval properly contain `other'?
do
Result := is_equal (other)
end
feature -- Output
as_string: STRING
do
Result := primitive_value_out (lower)
end
end