Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
NaiJi ✨ | 1401e51918 |
|
@ -15,7 +15,9 @@ template <class TNote,
|
||||||
class Timeline
|
class Timeline
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Timeline() : _current_offset(0) {}
|
explicit Timeline() : _current_offset(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
typedef typename std::set<TNote *>::const_iterator Iterator;
|
typedef typename std::set<TNote *>::const_iterator Iterator;
|
||||||
|
|
||||||
|
@ -24,30 +26,30 @@ class Timeline
|
||||||
_current_offset = offset;
|
_current_offset = offset;
|
||||||
expire(_top_note);
|
expire(_top_note);
|
||||||
|
|
||||||
if (!_timeline.empty())
|
if (_timeline.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Iterator head_iterator = _timeline.begin();
|
||||||
|
|
||||||
|
while (!isExpired(head_iterator))
|
||||||
{
|
{
|
||||||
Iterator head_iterator = _timeline.begin();
|
if ((*head_iterator)->getPerfectOffset() >= offset)
|
||||||
|
|
||||||
while (!isExpired(head_iterator))
|
|
||||||
{
|
{
|
||||||
if ((*head_iterator)->getPerfectOffset() >= offset)
|
Iterator pre_head = head_iterator;
|
||||||
{
|
--pre_head;
|
||||||
Iterator pre_head = head_iterator;
|
|
||||||
--pre_head;
|
|
||||||
|
|
||||||
_top_note =
|
_top_note =
|
||||||
!isExpired(pre_head) && (*pre_head)->isActive(offset)
|
!isExpired(pre_head) && (*pre_head)->isActive(offset)
|
||||||
? pre_head
|
? pre_head
|
||||||
: head_iterator;
|
: head_iterator;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
++head_iterator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isExpired(_top_note))
|
++head_iterator;
|
||||||
_top_note = _timeline.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isExpired(_top_note))
|
||||||
|
_top_note = _timeline.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNotes(const std::set<TNote *, NotePtrComparator> ¬es)
|
void setNotes(const std::set<TNote *, NotePtrComparator> ¬es)
|
||||||
|
@ -128,11 +130,20 @@ class Timeline
|
||||||
iterator = _timeline.end();
|
iterator = _timeline.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Iterator getTopNote() const noexcept { return _top_note; }
|
inline Iterator getTopNote() const noexcept
|
||||||
|
{
|
||||||
|
return _top_note;
|
||||||
|
}
|
||||||
|
|
||||||
inline Iterator begin() const noexcept { return _timeline.begin(); }
|
inline Iterator begin() const noexcept
|
||||||
|
{
|
||||||
|
return _timeline.begin();
|
||||||
|
}
|
||||||
|
|
||||||
inline Iterator end() const noexcept { return _timeline.end(); }
|
inline Iterator end() const noexcept
|
||||||
|
{
|
||||||
|
return _timeline.end();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<TNote *, NotePtrComparator> _timeline;
|
std::set<TNote *, NotePtrComparator> _timeline;
|
||||||
|
|
Loading…
Reference in New Issue