Add ImmutableList::contains(). Patch by Rui Paulo!
authorNick Lewycky <nicholas@mxc.ca>
Wed, 6 Jul 2011 21:59:48 +0000 (21:59 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 6 Jul 2011 21:59:48 +0000 (21:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134545 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/ImmutableList.h

index 714355b95131c7a05e7706aff55730dd77b9ceff..d7c0074a9f0827e83f5b9a07abd06a07ada6e095 100644 (file)
@@ -103,6 +103,14 @@ public:
   /// isEmpty - Returns true if the list is empty.
   bool isEmpty() const { return !X; }
 
+  bool contains(const T& V) const {
+    for (iterator I = begin(), E = end(); I != E; ++I) {
+      if (*I == V)
+        return true;
+    }
+    return false;
+  }
+
   /// isEqual - Returns true if two lists are equal.  Because all lists created
   ///  from the same ImmutableListFactory are uniqued, this has O(1) complexity
   ///  because it the contents of the list do not need to be compared.  Note