(svn r20951) -Codechange: Add SmallMap::Contains() and use it.

This commit is contained in:
frosch
2010-10-16 20:34:43 +00:00
parent 82d4ffacff
commit 98250ad8da
5 changed files with 16 additions and 5 deletions

View File

@@ -54,6 +54,16 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
return this->End();
}
/**
* Tests whether a key is assigned in this map.
* @param key key to test
* @return true iff the item is present
*/
FORCEINLINE bool Contains(const T &key)
{
return this->Find(key) != this->End();
}
/**
* Removes given pair from this map
* @param pair pair to remove
@@ -90,7 +100,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
*/
FORCEINLINE bool Insert(const T &key, const U &data)
{
if (this->Find(key) != this->End()) return false;
if (this->Contains(key)) return false;
Pair *n = this->Append();
n->first = key;
n->second = data;