5
5
/**
6
6
* Interval is a pair of numbers or a pair of any comparable objects on which may be defined predicates
7
7
* *equal*, *less* and method *max(p1, p1)* that returns maximum in a pair.
8
- * When interval is an object rather than pair of numbers, this object should have properties *low*, *high*, *max*
8
+ * When interval is an object rather than a pair of numbers, this object should have properties *low*, *high*, *max*
9
9
* and implement methods *less_than(), equal_to(), intersect(), not_intersect(), clone(), output()*.
10
10
* Two static methods *comparable_max(), comparable_less_than()* define how to compare values in pair. <br/>
11
11
* This interface is described in typescript definition file *index.d.ts*
@@ -51,7 +51,7 @@ const Interval = class Interval {
51
51
*/
52
52
less_than ( other_interval ) {
53
53
return this . low < other_interval . low ||
54
- this . low == other_interval . low && this . high < other_interval . high ;
54
+ this . low === other_interval . low && this . high < other_interval . high ;
55
55
}
56
56
57
57
/**
@@ -60,7 +60,7 @@ const Interval = class Interval {
60
60
* @returns {boolean }
61
61
*/
62
62
equal_to ( other_interval ) {
63
- return this . low == other_interval . low && this . high == other_interval . high ;
63
+ return this . low === other_interval . low && this . high = == other_interval . high ;
64
64
}
65
65
66
66
/**
@@ -83,13 +83,15 @@ const Interval = class Interval {
83
83
84
84
/**
85
85
* Returns new interval merged with other interval
86
- * @param {Interval } interval - Other interval to merge with
86
+ * @param {Interval } other_interval - Other interval to merge with
87
87
* @returns {Interval }
88
88
*/
89
89
merge ( other_interval ) {
90
90
return new Interval (
91
- this . low === undefined ? other_interval . low : Math . min ( this . low , other_interval . low ) ,
92
- this . high === undefined ? other_interval . high : Math . max ( this . high , other_interval . high )
91
+ this . low === undefined ?
92
+ other_interval . low : ( this . low < other_interval . low ? this . low : other_interval . low ) ,
93
+ this . high === undefined ?
94
+ other_interval . high : ( this . high > other_interval . high ? this . high : other_interval . high )
93
95
) ;
94
96
}
95
97
0 commit comments