note description: "Intervals between absolute values" legal: "See notice at end of class." status: "See notice at end of class." date: "$Date: 2018-12-18 10:46:58 +0000 (Tue, 18 Dec 2018) $" revision: "$Revision: 102623 $" class interface INTERVAL [G -> ABSOLUTE] create make feature -- Initialization make (s, e: G) -- Sets start_bound and end_bound to s and e respectively. require start_exists: s /= Void end_exists: e /= Void start_before_end: s <= e ensure start_bound_set: start_bound /= Void and then deep_equal (start_bound, s) end_bound_set: end_bound /= Void and then deep_equal (end_bound, e) feature -- Access start_bound: G -- Start bound of the current interval. end_bound: G -- End bound of the current interval. feature -- Measurement duration: DURATION -- Length of the interval. feature -- Comparison is_equal (other: like Current): BOOLEAN -- Is current interval equal to other? intersects (other: like Current): BOOLEAN -- Does current interval intersect other? require other_exists: other /= Void is_less alias "<" (other: like Current): BOOLEAN -- Is current interval strictly before other? is_less_equal alias "<=" (other: like Current): BOOLEAN -- Is current interval before other? is_greater alias ">" (other: like Current): BOOLEAN -- Is current interval after other? is_greater_equal alias ">=" (other: like Current): BOOLEAN -- Is current interval after other? is_strict_included_by (other: like Current): BOOLEAN -- Is current interval strictly included by other? strict_includes (other: like Current): BOOLEAN -- Does current interval strictly include other? is_included_by (other: like Current): BOOLEAN -- Is current interval included by other? includes (other: like Current): BOOLEAN -- Does current interval include other? overlaps (other: like Current): BOOLEAN -- Does current interval overlap other? require other_exists: other /= Void ensure result_defition: Result = (strict_before (other.end_bound) and has (other.start_bound)) symmetry: Result = other.is_overlapped_by (Current) is_overlapped_by (other: like Current): BOOLEAN -- Is current interval overlapped by other? require other_exists: other /= Void ensure symmetry: Result = other.overlaps (Current) meets (other: like Current): BOOLEAN -- Does current interval meet other? require other_exists: other /= Void ensure symmetry: Result = other.is_met_by (Current) result_definition: Result = (Current <= other and intersects (other)) is_met_by (other: like Current): BOOLEAN -- Is current interval met by other? require other_exists: other /= Void ensure symmetry: Result = other.meets (Current) feature -- Status report empty: BOOLEAN -- Is current interval empty? ensure result_definition: Result = duration.is_equal (duration.zero) has (v: G): BOOLEAN -- Does current interval have v between its bounds? require exists: v /= Void ensure result_definition: Result xor not (start_bound <= v and then end_bound >= v) strict_before (v: G): BOOLEAN -- Is the current interval strictly before v? require exists: v /= Void ensure result_definition: Result = (end_bound < v) strict_after (v: G): BOOLEAN -- Is the current interval strictly after v? require exists: v /= Void ensure result_definition: Result = (start_bound > v) before (v: G): BOOLEAN -- Is the current interval before v? require exists: v /= Void ensure result_definition: Result = (end_bound <= v) after (v: G): BOOLEAN -- Is the current interval after v? require exists: v /= Void ensure result_definition: Result = (start_bound >= v) feature -- Element change set_start_bound (s: G) -- Set start_bound to s. require start_bound_exists: s /= Void start_before_end_bound: s <= end_bound ensure start_bound_set: equal (start_bound, s) set_end_bound (e: G) -- Set end_bound to e. require end_bound_exists: e /= Void end_after_start_bound: e >= start_bound ensure end_bound_set: equal (end_bound, e) feature -- Basic operations union (other: like Current): like Current -- Union with other. require other_exists: other /= Void intersects: intersects (other) ensure result_exists: Result /= Void result_includes_current: Result.includes (Current) result_includes_other: Result.includes (other) intersection (other: like Current): detachable like Current -- Intersection with other. require other_exists: other /= Void ensure intersects_validity: intersects (other) = attached Result result_is_included_by_current: attached Result implies includes (Result) result_is_included_by_other: attached Result implies other.includes (Result) gather (other: like Current): like Current -- Union of other and current interval if other meets -- current interval. require other_exist: other /= Void meeting_interval: meets (other) ensure result_exist: Result /= Void result_same_as_union: Result.is_equal (union (other)) feature -- Output out: STRING_8 -- Printable representation of the current interval. invariant start_bound_exists: start_bound /= Void end_bound_exists: end_bound /= Void start_bound_before_end_bound: start_bound <= end_bound current_intersection: intersection (Current) ~ Current current_union: union (Current).is_equal (Current) has_bounds: has (start_bound) and has (end_bound) between_bound: after (start_bound) and before (end_bound) note copyright: "Copyright (c) 1984-2018, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class INTERVAL
Generated by ISE EiffelStudio