-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathdouble-range.ts
71 lines (65 loc) · 1.4 KB
/
double-range.ts
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
/**
* The `DoubleRange` class represents a numeric range with minimum and maximum values.
*
* @private
*/
export class DoubleRange {
private mStart: number;
private mEnd: number;
//private mIsEmpty: boolean;
/**
* Gets the start value.
*
* @returns {number} - The start value.
* @private
*/
get start(): number {
return this.mStart;
}
/**
* Gets the end value.
*
* @returns {number} - The end value.
* @private
*/
get end(): number {
return this.mEnd;
}
/*
get isEmpty(): boolean {
return this.mIsEmpty;
}*/
/**
* Gets the delta value.
*
* @returns {number} - The delta value.
* @private
*/
get delta(): number {
return (this.mEnd - this.mStart);
}
/**
* Gets the median value.
*
* @returns {number} - The median value.
* @private
*/
get median(): number {
return this.mStart + (this.mEnd - this.mStart) / 2;
}
constructor(start: number, end: number) {
/*
if (!isNaN(start) && !isNaN(end)) {
this.mIsEmpty = true;
} else {
this.mIsEmpty = false;
}*/
if (start < end) {
this.mStart = start;
this.mEnd = end;
} else {
this.mStart = end;
this.mEnd = start;
}
}
}