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
119
120
121
122
123
124
125
126
127
128
use std::ops::{RangeFrom, Add, Sub, AddAssign, SubAssign};
use crate::*;
use crate::error::TimeError;
impl<T:TimePoint> TimeWindow for RangeFrom<T>
{
type TimePoint = T;
#[inline] fn is_empty(&self) -> bool { self.lower_bound().is_future_infinite() }
#[inline] fn is_singleton(&self) -> bool { false }
#[inline] fn is_bounded(&self) -> bool { false }
#[inline] fn is_low_bounded(&self) -> bool { self.lower_bound().is_finite() }
#[inline] fn is_up_bounded(&self) -> bool { false }
#[inline] fn is_convex(&self) -> bool { true }
#[inline] fn lower_bound(&self) -> Self::TimePoint { self.start }
#[inline] fn upper_bound(&self) -> Self::TimePoint { Self::TimePoint::INFINITE }
}
impl<T:TimePoint> From<RangeFrom<T> > for TimeInterval<T>
{
#[inline]
fn from(range: RangeFrom<T>) -> Self {
assert!( !range.start.is_future_infinite() );
TimeInterval { lower: range.start, upper: T::INFINITE}
}
}
impl<T> AddAssign<RangeFrom<TimeValue>> for TimeInterval<T>
where T:TimePoint+AddAssign<TimeValue>
{
#[inline]
fn add_assign(&mut self, other: RangeFrom<TimeValue>) {
self.lower += other.lower_bound();
assert!( !self.lower.is_future_infinite() );
self.upper = T::INFINITE;
}
}
impl<T> SubAssign<RangeFrom<TimeValue>> for TimeInterval<T>
where T:TimePoint+SubAssign<TimeValue>
{
#[inline]
fn sub_assign(&mut self, other: RangeFrom<TimeValue>) {
self.upper -= other.lower_bound();
assert!( !self.upper.is_past_infinite() );
self.lower = -T::INFINITE;
}
}
impl<T> Add<RangeFrom<TimeValue>> for TimeInterval<T>
where T:TimePoint+Add<TimeValue,Output=T>
{
type Output = Self;
#[inline]
fn add(self, other: RangeFrom<TimeValue>) -> Self::Output {
TimeInterval::after(self.lower + other.lower_bound()).unwrap()
}
}
impl<T> Sub<RangeFrom<TimeValue>> for TimeInterval<T>
where T:TimePoint+Sub<TimeValue,Output=T>
{
type Output = Self;
#[inline]
fn sub(self, other: RangeFrom<TimeValue>) -> Self::Output {
TimeInterval::before(self.upper - other.lower_bound()).unwrap()
}
}
impl Add<RangeFrom<Timestamp>> for TimeSpan
{
type Output = TimeSlot;
#[inline]
fn add(self, other: RangeFrom<Timestamp>) -> Self::Output {
TimeInterval::after(self.lower + other.lower_bound()).unwrap()
}
}
impl Sub<RangeFrom<Timestamp>> for TimeSpan
{
type Output = TimeSlot;
#[inline]
fn sub(self, other: RangeFrom<Timestamp>) -> Self::Output {
TimeInterval::before(self.upper - other.lower_bound()).unwrap()
}
}
impl<T> AddAssign<RangeFrom<TimeValue>> for TimeSet<T>
where T:TimePoint+Add<TimeValue,Output=T>
{
#[inline]
fn add_assign(&mut self, other: RangeFrom<TimeValue>) {
*self += TimeSpan::from(other)
}
}
impl<T> SubAssign<RangeFrom<TimeValue>> for TimeSet<T>
where T:TimePoint+Sub<TimeValue,Output=T>
{
#[inline]
fn sub_assign(&mut self, other: RangeFrom<TimeValue>) {
*self -= TimeSpan::from(other)
}
}
impl<T> Add<RangeFrom<TimeValue>> for TimeSet<T>
where T:TimePoint+Add<TimeValue,Output=T>
{
type Output = TimeInterval<T>;
#[inline]
fn add(self, other: RangeFrom<TimeValue>) -> Self::Output {
TimeInterval::after(self.lower_bound() + other.lower_bound()).unwrap()
}
}
impl<T> Sub<RangeFrom<TimeValue>> for TimeSet<T>
where T:TimePoint+Sub<TimeValue,Output=T>
{
type Output = TimeInterval<T>;
#[inline] fn sub(self, other: RangeFrom<TimeValue>) -> Self::Output {
TimeInterval::before(self.upper_bound() - other.upper_bound()).unwrap()
}
}