From 98250ad8da83fe6f842437bb614df28a1fe217c6 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 16 Oct 2010 20:34:43 +0000 Subject: (svn r20951) -Codechange: Add SmallMap::Contains() and use it. --- src/core/smallmap_type.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp index 8689447c1..7c0186689 100644 --- a/src/core/smallmap_type.hpp +++ b/src/core/smallmap_type.hpp @@ -54,6 +54,16 @@ struct SmallMap : SmallVector, 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, 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; -- cgit v1.2.3-54-g00ecf