Map<> got the new method findFirstKey<>(), which is needed for the upcoming Dispatcher logic

This commit is contained in:
Pavel Kirienko
2014-03-18 14:58:05 +04:00
parent c7d6bcbdda
commit b5e201647f
2 changed files with 61 additions and 0 deletions
+33
View File
@@ -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());