summaryrefslogtreecommitdiff
path: root/src/core/smallmap_type.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/smallmap_type.hpp')
-rw-r--r--src/core/smallmap_type.hpp12
1 files changed, 11 insertions, 1 deletions
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
@@ -55,6 +55,16 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
}
/**
+ * 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
* @note it has to be pointer to pair in this map. It is overwritten by the last item.
@@ -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;