[llvm-commits] [llvm] r134545 - /llvm/trunk/include/llvm/ADT/ImmutableList.h

Nick Lewycky nicholas at mxc.ca
Wed Jul 6 14:59:48 PDT 2011


Author: nicholas
Date: Wed Jul  6 16:59:48 2011
New Revision: 134545

URL: http://llvm.org/viewvc/llvm-project?rev=134545&view=rev
Log:
Add ImmutableList::contains(). Patch by Rui Paulo!

Modified:
    llvm/trunk/include/llvm/ADT/ImmutableList.h

Modified: llvm/trunk/include/llvm/ADT/ImmutableList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableList.h?rev=134545&r1=134544&r2=134545&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableList.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableList.h Wed Jul  6 16:59:48 2011
@@ -103,6 +103,14 @@
   /// 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





More information about the llvm-commits mailing list