[PATCH] D18578: BitVector: Add insert() and erase() methods.
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 14:34:59 PDT 2016
MatzeB created this revision.
MatzeB added reviewers: dblaikie, echristo, qcolombet.
MatzeB added a subscriber: llvm-commits.
MatzeB set the repository for this revision to rL LLVM.
Herald added a subscriber: mcrosier.
This allows BitVector to be used in contexts exepcting a std::set or
DenseSet like API.
Repository:
rL LLVM
http://reviews.llvm.org/D18578
Files:
include/llvm/ADT/BitVector.h
Index: include/llvm/ADT/BitVector.h
===================================================================
--- include/llvm/ADT/BitVector.h
+++ include/llvm/ADT/BitVector.h
@@ -295,6 +295,23 @@
return *this;
}
+ /// Set bit \p Idx to true. This function allows BitVector to be used in
+ /// contexts expecting std::set/DenseSet like API.
+ std::pair<reference, bool> insert(unsigned Idx) {
+ reference ref(*this, Idx);
+ bool Res = !ref;
+ ref = true;
+ return std::make_pair(ref, Res);
+ }
+
+ /// Clear bit \p Idx. This function allows BitVector to be used in contexts
+ /// expecting std::set/DenseSet like API.
+ bool erase(unsigned Idx) {
+ bool Res = test(Idx);
+ reset(Idx);
+ return Res;
+ }
+
BitVector &flip() {
for (unsigned i = 0; i < NumBitWords(size()); ++i)
Bits[i] = ~Bits[i];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18578.51985.patch
Type: text/x-patch
Size: 844 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160329/48319b9d/attachment.bin>
More information about the llvm-commits
mailing list