[PATCH] D83449: [llvm] Add contains(KeyType) -> bool methods to Set types.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 11:27:01 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd3ce3dc4867b: [llvm] Add contains(KeyType) -> bool methods to DenseSet (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D83449?vs=278364&id=278863#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83449/new/

https://reviews.llvm.org/D83449

Files:
  llvm/include/llvm/ADT/DenseSet.h
  llvm/unittests/ADT/DenseSetTest.cpp


Index: llvm/unittests/ADT/DenseSetTest.cpp
===================================================================
--- llvm/unittests/ADT/DenseSetTest.cpp
+++ llvm/unittests/ADT/DenseSetTest.cpp
@@ -227,7 +227,7 @@
   Map.insert(B);
   EXPECT_EQ(Map.count(B), 1u);
   EXPECT_EQ(Map.count(C), 1u);
-  EXPECT_NE(Map.find(B), Map.end());
-  EXPECT_NE(Map.find(C), Map.end());
+  EXPECT_TRUE(Map.contains(B));
+  EXPECT_TRUE(Map.contains(C));
 }
 }
Index: llvm/include/llvm/ADT/DenseSet.h
===================================================================
--- llvm/include/llvm/ADT/DenseSet.h
+++ llvm/include/llvm/ADT/DenseSet.h
@@ -173,6 +173,11 @@
     return ConstIterator(TheMap.find(V));
   }
 
+  /// Check if the set contains the given element.
+  bool contains(const_arg_type_t<ValueT> V) const {
+    return TheMap.find(V) != TheMap.end();
+  }
+
   /// Alternative version of find() which allows a different, and possibly less
   /// expensive, key type.
   /// The DenseMapInfo is responsible for supplying methods


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83449.278863.patch
Type: text/x-patch
Size: 1020 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200717/dabd98ae/attachment.bin>


More information about the llvm-commits mailing list