-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrangelist.cpp
More file actions
50 lines (47 loc) · 1.12 KB
/
rangelist.cpp
File metadata and controls
50 lines (47 loc) · 1.12 KB
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
#include "rangelist.h"
RangeLookupIterator::RangeLookupIterator(RangeList &RL, int posMs, int expandBy) :
SearchStartAtMs(posMs),
ExpandBy(expandBy),
Cur(RL.subsAheadOf(SearchStartAtMs - ExpandBy)),
Begin(RL.begin()),
End(RL.end()),
Result(RL.end())
{
if(Cur == End)
{
--Cur;
}
while(Cur != Begin && Cur->Time.EndTime >= SearchStartAtMs + ExpandBy)
{
--Cur;
}
++(*this);
}
RangeLookupIterator::RangeLookupIterator(RangeList &RL) :
SearchStartAtMs(0),
ExpandBy(0),
Cur(RL.end()),
Begin(RL.begin()),
End(RL.end()),
Result(RL.end())
{ }
RangeLookupIterator &RangeLookupIterator::operator ++()
{
Result = End;
while(Cur >= Begin && Cur != End)
{
std::vector<SrtSubtitle>::iterator Tmp = Cur;
++Cur;
if(Tmp->Time.StartTime > SearchStartAtMs + ExpandBy)
{
break;
}
else if(Tmp->Time.StartTime <= SearchStartAtMs + ExpandBy &&
Tmp->Time.EndTime >= SearchStartAtMs - ExpandBy)
{
Result = Tmp;
break;
}
}
return *this;
}