Unverified 提交 2a0f14bf authored 作者: penguinol's avatar penguinol 提交者: GitHub

SeqManager.cpp: fix num discontinued problem and increase performance (#396)

上级 26b2df1e
#define MS_CLASS "RTC::SeqManager"
// #define MS_LOG_DEV_LEVEL 3
#include <iterator>
#include "RTC/SeqManager.hpp"
#include "Logger.hpp"
......@@ -94,8 +95,8 @@ namespace RTC
}
// Count dropped entries before 'input' in order to adapt the base.
size_t dropped = std::count_if(
this->dropped.begin(), this->dropped.end(), [&input](T i) { return i < input; });
size_t dropped = this->dropped.size()
- std::distance(this->dropped.upper_bound(input) , this->dropped.end());
base -= dropped;
}
......
......@@ -402,4 +402,26 @@ SCENARIO("SeqManager", "[rtc]")
SeqManager<uint16_t> seqManager;
validate(seqManager, inputs);
}
SECTION("sync and drop some input near max-value")
{
// clang-format off
std::vector<TestSeqManagerInput<uint16_t>> inputs =
{
{ 65530, 1, true, false },
{ 65531, 2, false, false },
{ 65532, 3, false, false },
{ 65533, 0, false, true },
{ 65534, 0, false, true },
{ 65535, 4, false, false },
{ 0, 5, false, false },
{ 1, 6, false, false },
{ 2, 7, false, false },
{ 3, 8, false, false }
};
// clang-format on
SeqManager<uint16_t> seqManager;
validate(seqManager, inputs);
}
}
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论