-
Notifications
You must be signed in to change notification settings - Fork 3
/
interval.e
executable file
·121 lines (94 loc) · 2.76 KB
/
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
note
component: "Eiffel Object Modelling Framework"
description: "[
Abstract generic class defining an interval (i.e. range) of a comparable type, allowing half-ranges, i.e. with
-infinity as lower limit or +infinity as upper limit.
FIXME: should really be defined as INTERVAL[COMPARABLE] but DATE_TIME_DURATION (one of the types occurring
as a generic parameter of this type) is strangely only PART_COMPARABLE.
]"
keywords: "intervals"
author: "Thomas Beale <[email protected]>"
support: "http://www.openehr.org/issues/browse/AWB"
copyright: "Copyright (c) 2000- Ocean Informatics Pty Ltd <http://www.oceaninfomatics.com>"
license: "Apache 2.0 License <http://www.apache.org/licenses/LICENSE-2.0.html>"
deferred class INTERVAL [G -> PART_COMPARABLE]
inherit
ANY
redefine
out, is_equal
end
feature -- Access
lower: detachable G
-- lower limit of interval
upper: detachable G
-- upper limit of interval
deferred
end
midpoint: detachable G
-- generate midpoint of limits
deferred
end
feature -- Status report
lower_unbounded: BOOLEAN
-- True if lower limit open, i.e. -infinity
deferred
end
upper_unbounded: BOOLEAN
-- True if upper limit open, i.e. +infinity
deferred
end
lower_included: BOOLEAN
-- True if lower limit point included in interval
deferred
end
upper_included: BOOLEAN
-- True if upper limit point included in interval
deferred
end
is_point: BOOLEAN
-- Is current interval a point (width = 0)?
deferred
end
unbounded: BOOLEAN
-- True if interval is completely open
deferred
end
feature -- Comparison
has (v: G): BOOLEAN
-- Does current interval have `v' between its bounds?
deferred
end
intersects (other: INTERVAL [G]): BOOLEAN
-- True if there is any overlap between intervals represented by Current and other
deferred
end
contains (other: INTERVAL [G]): BOOLEAN
-- Does current interval properly contain `other'? True if at least one limit of other
-- is strictly inside the limits of this interval
deferred
end
feature -- Comparison
is_equal (other: like Current): BOOLEAN
-- True if current object's interval is semantically same as `other'
-- even if the concrete types are different
do
Result :=
lower ~ other.lower and
upper ~ other.upper and
upper_included = other.upper_included and
upper_unbounded = other.upper_unbounded and
lower_included = other.lower_included and
lower_unbounded = other.lower_unbounded
end
feature -- Output
as_string: STRING
deferred
end
out: STRING
do
Result := as_string
end
invariant
lower_attached_if_bounded: not lower_unbounded implies attached lower
upper_attached_if_bounded: not upper_unbounded implies attached upper
end