mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 23:43:33 +08:00
Map<> got the new method findFirstKey<>(), which is needed for the upcoming Dispatcher logic
This commit is contained in:
@@ -268,6 +268,39 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Predicate>
|
||||
const Key* findFirstKey(Predicate predicate) const
|
||||
{
|
||||
for (unsigned int i = 0; i < NumStaticEntries; i++)
|
||||
{
|
||||
if (!static_[i].match(Key()))
|
||||
{
|
||||
if (predicate(static_[i].key, static_[i].value))
|
||||
{
|
||||
return &static_[i].key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KVGroup* p = list_.get();
|
||||
while (p)
|
||||
{
|
||||
for (int i = 0; i < KVGroup::NumKV; i++)
|
||||
{
|
||||
const KVPair* const kv = p->kvs + i;
|
||||
if (!kv->match(Key()))
|
||||
{
|
||||
if (predicate(kv->key, kv->value))
|
||||
{
|
||||
return &p->kvs[i].key;
|
||||
}
|
||||
}
|
||||
}
|
||||
p = p->getNextListNode();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void removeAll()
|
||||
{
|
||||
removeWhere(YesPredicate());
|
||||
|
||||
Reference in New Issue
Block a user