summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/SparseBitVector.h
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2007-09-16 23:59:53 +0000
committerDaniel Berlin <dberlin@dberlin.org>2007-09-16 23:59:53 +0000
commitc6d939818b7c50f6e14d04447657e670aedc3f6f (patch)
treeb52e9ffe6d5aa1c4067e52d9892c10b0ea12a1b1 /include/llvm/ADT/SparseBitVector.h
parent7f44657c2f4409416a083a9e63d2b4ea7cdca43e (diff)
downloadllvm-c6d939818b7c50f6e14d04447657e670aedc3f6f.tar.gz
llvm-c6d939818b7c50f6e14d04447657e670aedc3f6f.tar.bz2
llvm-c6d939818b7c50f6e14d04447657e670aedc3f6f.tar.xz
Fix bug in andersen's related to test_and_set.
Add operator == and != to SparseBitVector. Simplify code for test_and_set git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SparseBitVector.h')
-rw-r--r--include/llvm/ADT/SparseBitVector.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/include/llvm/ADT/SparseBitVector.h b/include/llvm/ADT/SparseBitVector.h
index 5622aab654..6ffc6edcfc 100644
--- a/include/llvm/ADT/SparseBitVector.h
+++ b/include/llvm/ADT/SparseBitVector.h
@@ -128,9 +128,11 @@ public:
bool test_and_set (unsigned Idx) {
bool old = test(Idx);
- if (!old)
+ if (!old) {
set(Idx);
- return !old;
+ return true;
+ }
+ return false;
}
void reset(unsigned Idx) {
@@ -533,9 +535,29 @@ public:
bool test_and_set (unsigned Idx) {
bool old = test(Idx);
- if (!old)
+ if (!old) {
set(Idx);
- return !old;
+ return true;
+ }
+ return false;
+ }
+
+ bool operator!=(const SparseBitVector &RHS) {
+ return !(*this == RHS);
+ }
+
+ bool operator==(const SparseBitVector &RHS) {
+ ElementListConstIter Iter1 = Elements.begin();
+ ElementListConstIter Iter2 = RHS.Elements.begin();
+
+ while (Iter2 != RHS.Elements.end()) {
+ if (Iter1->index() != Iter2->index()
+ || *Iter1 != *Iter2)
+ return false;
+ ++Iter1;
+ ++Iter2;
+ }
+ return Iter1 == Elements.end();
}
// Union our bitmap with the RHS and return true if we changed.