Interval
- Companion:
- object
Value members
Concrete methods
Canonical
Canonical
A canonical form of an interval is where the interval is closed on both starting and finishing sides:
[a-, a+]
Deflate
Deflate
Applies succ and pred functions to the left and right boundaries of an interval reducing it it.
When deflating, the operation might produce an empty interval, where left boundary is greater than the right boundary.
[a-, a+] -> [succ(a-), pred(a+)]
Example:
deflate([1, 2]) = [2, 1]
Deflate the left side of the interval
Deflate the left side of the interval
[a-, a+] -> [succ(a-), a+]
Example:
deflateLeft([1, 2]) = [2, 2]
Deflate the right side of the interval
Deflate the right side of the interval
[a-, a+] -> [a-, pred(a+)]
Example:
deflateRight([1, 2]) = [1, 1]
Inflate
Inflate
Applies pred and succ functions to the left and right boundaries of an interval extending it.
[a-, a+] -> [pred(a-), succ(a+)]
Example:
inflate([1, 2]) = [0, 3]
Inflate only the left side of the interval
Inflate only the left side of the interval
[a-, a+] -> [pred(a-), a+]
Example:
inflateLeft([1, 2]) = [0, 2]
Inflate only the right side of the interval
Inflate only the right side of the interval
[a-, a+] -> [a-, succ(a+)]
Example:
inflateLeft([1, 2]) = [0, 3]
Returns true if the interval is empty and false otherwise.
Returns true if the interval is empty and false otherwise.
Returns true if the interval is degenerate (a point) or false otherwise.
Returns true if the interval is degenerate (a point) or false otherwise.
Returns true if the interval is proper and false otherwise.
Returns true if the interval is proper and false otherwise.
Returns true if the interval is non-empty and false otherwise.
Returns true if the interval is non-empty and false otherwise.
Returns true if the interval is not a point and false otherwise.
Returns true if the interval is not a point and false otherwise.
Returns true, if interval is not proper and false otherwise.
Returns true, if interval is not proper and false otherwise.
Inherited methods
Before, Precedes (b)
Before, Precedes (b)
PP (Point-Point):
{p}; {q}
p < q
PI (Point-Interval):
{p}; {a-, a+}
p < a-
II (Interval-Interval):
{a-, a+}; {b-, b+}
a- < b-
a- < b+
a+ < b-
a+ < b+
a- < a+ < b- < b+
Relation AAAAA
before(a,b) b : : BBBBBBBBB | a+ < b-
- Inherited from:
- BasicRel (hidden)
During, ProperlyIncludedIn (d)
During, ProperlyIncludedIn (d)
PI (Point-Interval):
{p}; {a-, a+}
a- < p < a+
II (Interval-Interval):
{a-, a+}; {b-; b+}
a- > b-
a- < b+
a+ > b-
a+ < b+
b- < a- < a+ < b+
Relation AAAAA
during(a,b) d|D BBBBBBBBB | a- > b- ; a+ < b+
- Inherited from:
- BasicRel (hidden)
Equals (e)
Equals (e)
A = B
PP (Point-Point):
{p}; {q}
p = q
II (Interval-Interval):
{a-, a+}; {b-; b+}
a- = b-
a- < b+
a+ > b-
a+ = b+
a- = b- < a+ = b+
Relation AAAAA
equalsTo(a, b) e BBBBB | a- = b- ; a+ = b+
- Inherited from:
- BasicRel (hidden)
Finishes, Ends (f)
Finishes, Ends (f)
PI (Point-Interval):
{p}; {a-, a+}
p = a+
II (Interval-Interval):
{a-, a+}; {b-; b+}
a- > b-
a- < b+
a+ > b-
a+ = b+
b- < a- < a+ = b+
Relation AAAAA
finishes(a,b) f|F BBBBBBBBB | a+ = b+ ; a- > b-
- Inherited from:
- BasicRel (hidden)
Gap (Complement)
Gap (Complement)
- A ∥ B
A gap between two intervals a
and b
: a ∥ b := [succ(min(a+, b+)), pred(max(a-, b-))]
.
A ∥ B := [succ(min(a+, b+)), pred(max(a-, b-))]
[***********] | [5,10]
[***********] | [15,20]
[******] | [11,14]
--+-----------+-+------+-+-----------+-- |
5 10 11 14 15 20 |
Laws:
- Commutative: A ∥ B = B ∥ A
- Inherited from:
- BasicOps (hidden)
Intersection
Intersection
- A ∩ B
- A & B
An intersection of two intervals a
and b
is defined as the interval c
, such that c = a ∩ b := [max(a-, b-), min(a+, b+)]
.
A ∩ B := [max(a-, b-), min(a+, b+)]
[******************] | [5,10]
[**********************] | [1,7]
[******] | [5,7]
--+---------------+------+-----------+-- |
1 5 7 10 |
Laws:
- Commutative: A & B = B & A
- Associative: (A & B) & C = A & (B & C)
- Inherited from:
- BasicOps (hidden)
Intersects
Intersects
Two intervals a
and b
are intersecting if:
a- <= b+
b- <= a+
Relation AAAAA
meets(a,b) m|M : BBBBBBBBB | a+ = b-
overlaps(a,b) o|O : BBBBBBBBB | a- < b- < a+ ; a+ < b+
starts(a,b) s|S BBBBBBBBB | a- = b- ; a+ < b+
during(a,b) d|D BBBBBBBBB | a- > b- ; a+ < b+
finishes(a,b) f|F BBBBBBBBB | a+ = b+ ; a- > b-
equals(a, b) e BBBBB | a- = b- ; a+ = b+
- Inherited from:
- ExtendedRel (hidden)
IsAdjacent
IsAdjacent
Two intervals a and b are adjacent if:
succ(a+) = b- OR succ(b+) = a-
before | b
after | B
- Inherited from:
- ExtendedRel (hidden)
IsDisjoint
IsDisjoint
Checks if there A and B are disjoint.
A and B are disjoint if A does not intersect B.
a+ < b-
a- > b+
before | b after | B }}}
- Inherited from:
- ExtendedRel (hidden)
IsGreater
IsGreater
Checks whether A is greater-than B (Order Relation)
A > B
b- < a-
- Inherited from:
- ExtendedRel (hidden)
IsLess
IsLess
Checks whether A is less-than B (Order Relation)
A < B
a- < b-
- Inherited from:
- ExtendedRel (hidden)
IsMergedBy
IsMergedBy
- Inherited from:
- ExtendedRel (hidden)
IsSubset
IsSubset
Checks whether A is a subset of B
A ⊆ B
a- >= b-
a+ <= b+
starts | s
during | d
finishes | f
equals | e
- Inherited from:
- ExtendedRel (hidden)
IsSuperset
IsSuperset
Checks whether A is a superset of B
A ⊇ B
b- >= a-
b+ <= a+
is-started-by | S
contains | D
is-finished-by | F
equals | e
- Inherited from:
- ExtendedRel (hidden)
Meets (m)
Meets (m)
II (Interval-Interval):
{a-, a+}; {b-; b+}
a- < b-
a- < b+
a+ = b-
a+ < b+
a- < a+ = b- < b+
Relation AAAAA
meets(a,b) m : BBBBBBBBB | a+ = b-
- Inherited from:
- BasicRel (hidden)
Merges
Merges
Two intervals a
and b
can be merged, if they are adjacent or intersect.
a- <= b+
b- <= a+
OR
succ(a+) = b- OR succ(b+) = a-
intersects(a,b)
isAdjacent(a,b)
- Inherited from:
- ExtendedRel (hidden)
Minus
Minus
Subtraction of two intervals, a
minus b
returns:
[a-, min(pred(b-), a+)]
if (a- < b-) and (a+ <= b+)[max(succ(b+), a-), a+]
if (a- >= b-) and (a+ > b+)
NOTE: a.minus(b)
is defined if and only if:
- (a)
a
andb
are disjoint; - (b)
a
contains eitherb-
orb+
but not both; - (c) either b.starts(a) or b.finishes(a) is true;
NOTE: a.minus(b)
is undefined if:
- either
a.starts(b)
ora.finishes(b)
; - either
a
orb
is properly included in the other;
Example #1: ((a- < b-) AND (a+ <= b+)) | [a-, min(pred(b-), a+)]
[**********************] | [1,10]
[************************] | [5,15]
[*******] | [1,4]
--+-------+-+------------+-----------+-- |
1 4 5 10 15 |
Example #2: ((a- >= b-) AND (a+ > b+)) | [max(succ(b+), a-), a+]
[************************] | [5,15]
[**********************] | [1,10]
[*********] | [11,15]
--+---------+------------+-+---------+-- |
1 5 10 15 |
- Inherited from:
- BasicOps (hidden)
Overlaps (o)
Overlaps (o)
II (Interval-Interval):
{a-, a+}; {b-; b+}
a- < b-
a- < b+
a+ > b-
a+ < b+
a- < b- < a+ < b+
Relation AAAAA
overlaps(a,b) o : BBBBBBBBB | a- < b- < a+ ; a+ < b+
- Inherited from:
- BasicRel (hidden)
Span
Span
- A # B
A span of two intervals a
and b
: a # b := [min(a-, b-), max(a+, b+)]
.
A # B := [min(a-, b-), max(a+, b+)]
Example #1:
[******************] | [5,10]
[**********************] | [1,7]
[**********************************] | [1,10]
--+---------------+------+-----------+-- |
1 5 7 10 |
Example #2: (disjoint Intervals):
[***************] | [1,5]
[***********] | [7,10]
[**********************************] | [1,10]
--+---------------+------+-----------+-- |
1 5 7 10 |
Laws:
- Commutative: A # B = B # A
- Associative: (A # B) # C = A # (B # C)
- Inherited from:
- BasicOps (hidden)
Starts, Begins (s)
Starts, Begins (s)
PI (Point-Interval):
{p}; {a-, a+}
p = a-
II (Interval-Interval):
{a-, a+}; {b-; b+}
a- = b-
a- < b+
a+ > b-
a+ < b+
a- = b- < a+ < b+
Relation AAAAA
starts(a,b) s|S BBBBBBBBB | a- = b- ; a+ < b+
- Inherited from:
- BasicRel (hidden)
Union
Union
- A ∪ B
A union of two intervals a
and b
: [min(a-,b-), max(a+,b+)]
if merges(a, b)
and undefined otherwise.
NOTE: merges
means that the intervals are adjacent
or intersecting
.
A union B := [min(a-,b-), max(a+,b+)] if merges(a, b) else ∅
Example #1:
[***************] | [1,5]
[***************] | [6,10]
[**********************************] | [1,10]
--+---------------+--+---------------+-- |
1 5 6 10 |
Example #2: (disjoint and non-adjacent Intervals):
[***********] | [1,4]
[***************] | [6,10]
| ∅
--+-----------+------+---------------+-- |
1 4 6 10 |
Laws:
- Commutative: A ∪ B = B ∪ A
- Inherited from:
- BasicOps (hidden)