summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/ImmutableList.h
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-07-06 21:59:48 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-07-06 21:59:48 +0000
commit298bc9a1a5161a5f6e5a0f35e8372d008ef6e812 (patch)
tree244d4722478b981c41e61f78ac30fce77203d03c /include/llvm/ADT/ImmutableList.h
parentd1689ae4b1ae5af191f71dcb9c59640a6dca7ebc (diff)
downloadllvm-298bc9a1a5161a5f6e5a0f35e8372d008ef6e812.tar.gz
llvm-298bc9a1a5161a5f6e5a0f35e8372d008ef6e812.tar.bz2
llvm-298bc9a1a5161a5f6e5a0f35e8372d008ef6e812.tar.xz
Add ImmutableList::contains(). Patch by Rui Paulo!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134545 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/ImmutableList.h')
-rw-r--r--include/llvm/ADT/ImmutableList.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/llvm/ADT/ImmutableList.h b/include/llvm/ADT/ImmutableList.h
index 714355b951..d7c0074a9f 100644
--- a/include/llvm/ADT/ImmutableList.h
+++ b/include/llvm/ADT/ImmutableList.h
@@ -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