Compare commits

...

1 Commits

Author SHA1 Message Date
NaiJi ✨ 1401e51918 chore: Inverse if-else tree in Timeline 2023-02-16 04:05:39 +04:00
1 changed files with 33 additions and 22 deletions

View File

@ -15,7 +15,9 @@ template <class TNote,
class Timeline
{
public:
explicit Timeline() : _current_offset(0) {}
explicit Timeline() : _current_offset(0)
{
}
typedef typename std::set<TNote *>::const_iterator Iterator;
@ -24,8 +26,9 @@ class Timeline
_current_offset = offset;
expire(_top_note);
if (!_timeline.empty())
{
if (_timeline.empty())
return;
Iterator head_iterator = _timeline.begin();
while (!isExpired(head_iterator))
@ -48,7 +51,6 @@ class Timeline
if (isExpired(_top_note))
_top_note = _timeline.begin();
}
}
void setNotes(const std::set<TNote *, NotePtrComparator> &notes)
{
@ -128,11 +130,20 @@ class Timeline
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:
std::set<TNote *, NotePtrComparator> _timeline;