Skip to content

Commit

Permalink
Lambdas were replaced by functors
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPinezhaninov committed Aug 4, 2020
1 parent 3c28fa2 commit 725cd1a
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions include/intervaltree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class IntervalTree
}

if (m_root != m_nill) {
subtreeOverlappingIntervals(m_root, interval, boundary, [&out] (const Interval &in) -> void { out.push_back(in); });
subtreeOverlappingIntervals(m_root, interval, boundary, Appender{out});
}

out.shrink_to_fit();
Expand All @@ -409,7 +409,7 @@ class IntervalTree
}

if (m_root != m_nill) {
subtreeInnerIntervals(m_root, interval, boundary, [&out] (const Interval &in) -> void { out.push_back(in); });
subtreeInnerIntervals(m_root, interval, boundary, Appender{out});
}

out.shrink_to_fit();
Expand All @@ -432,7 +432,7 @@ class IntervalTree
}

if (m_root != m_nill) {
subtreeOuterIntervals(m_root, interval, boundary, [&out] (const Interval &in) -> void { out.push_back(in); });
subtreeOuterIntervals(m_root, interval, boundary, Appender{out});
}

out.shrink_to_fit();
Expand All @@ -455,7 +455,7 @@ class IntervalTree
}

if (m_root != m_nill) {
subtreeIntervalsContainPoint(m_root, point, boundary, [&out] (const Interval &in) -> void { out.push_back(in); });
subtreeIntervalsContainPoint(m_root, point, boundary, Appender{out});
}

out.shrink_to_fit();
Expand All @@ -476,7 +476,7 @@ class IntervalTree
size_type count = 0;

if (m_root != m_nill) {
subtreeOverlappingIntervals(m_root, interval, boundary, [&count] (const Interval &) -> void { ++count; });
subtreeOverlappingIntervals(m_root, interval, boundary, Counter{count});
}

return count;
Expand All @@ -488,7 +488,7 @@ class IntervalTree
size_type count = 0;

if (m_root != m_nill) {
subtreeInnerIntervals(m_root, interval, boundary, [&count] (const Interval &) -> void { ++count; });
subtreeInnerIntervals(m_root, interval, boundary, Counter{count});
}

return count;
Expand All @@ -500,7 +500,7 @@ class IntervalTree
size_type count = 0;

if (m_root != m_nill) {
subtreeOuterIntervals(m_root, interval, boundary, [&count] (const Interval &) -> void { ++count; });
subtreeOuterIntervals(m_root, interval, boundary, Counter{count});
}

return count;
Expand All @@ -512,7 +512,7 @@ class IntervalTree
size_type count = 0;

if (m_root != m_nill) {
subtreeIntervalsContainPoint(m_root, point, boundary, [&count] (const Interval &) -> void { ++count; });
subtreeIntervalsContainPoint(m_root, point, boundary, Counter{count});
}

return count;
Expand Down Expand Up @@ -554,13 +554,36 @@ class IntervalTree
};


struct Appender final
{
template <typename Interval>
void operator()(Interval &&interval)
{
intervals.emplace_back(std::forward<Interval>(interval));
}

Intervals &intervals;
};


struct Counter final
{
template <typename Interval>
void operator()(Interval &&)
{
++count;
}

size_type &count;
};


struct HighComparator final
{
public:
template<typename T>
template <typename T>
bool operator()(const T &lhs, const T &rhs) const
{
return (lhs.high < rhs.high);
return (lhs.high < rhs.high);
}
};

Expand Down

0 comments on commit 725cd1a

Please sign in to comment.