[PATCH] D18578: BitVector: Add insert() and erase() methods.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 22:25:03 PDT 2016
Test cases?
Got a usage in mind?
On Tue, Mar 29, 2016 at 2:34 PM, Matthias Braun via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> 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];
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160329/6b468b9f/attachment.html>
More information about the llvm-commits
mailing list