[PATCH] D18579: SetVector: Add front, pop_front and resize operations
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 22:26:10 PDT 2016
Test cases?
Got use cases in mind? (specific new/incoming patches to LLVM projects that
will use this functionality)
& 'resize' seems like the wrong name for a set or map operation - perhaps
"reserve"? (I think there was a recent change for this rename in DenseMap,
right?)
On Tue, Mar 29, 2016 at 2:37 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.
>
> front() and pop_front() are useful if the underlying vector type is a
> std::dequeue.
> resize() allows the usage of BitVector as set type and tuning in the case
> of DenseSet/SmallPtrSet.
>
> Repository:
> rL LLVM
>
> http://reviews.llvm.org/D18579
>
> Files:
> include/llvm/ADT/SetVector.h
>
> Index: include/llvm/ADT/SetVector.h
> ===================================================================
> --- include/llvm/ADT/SetVector.h
> +++ include/llvm/ADT/SetVector.h
> @@ -116,6 +116,12 @@
> return vector_.back();
> }
>
> + /// Return the first element of the SetVector.
> + const T &front() const {
> + assert(!empty() && "Cannot call front() on empty SetVector!");
> + return vector_.front();
> + }
> +
> /// \brief Index into the SetVector.
> const_reference operator[](size_type n) const {
> assert(n < vector_.size() && "SetVector access out of range!");
> @@ -218,14 +224,33 @@
> return Ret;
> }
>
> + /// \brief Remove the first element of the SetVector, only available if
> the
> + /// underlying vector type supports the pop_front() operation.
> + void pop_front() {
> + assert(!empty() && "Cannot remove an element from an empty
> SetVector!");
> + set_.erase(front());
> + vector_.pop_front();
> + }
> +
> + T LLVM_ATTRIBUTE_UNUSED_RESULT pop_front_val() {
> + T Ret = front();
> + pop_front();
> + return Ret;
> + }
> +
> bool operator==(const SetVector &that) const {
> return vector_ == that.vector_;
> }
>
> bool operator!=(const SetVector &that) const {
> return vector_ != that.vector_;
> }
>
> + /// Call resize on the underlying set.
> + void resize(size_t size) {
> + set_.resize(size);
> + }
> +
> private:
> /// \brief A wrapper predicate designed for use with std::remove_if.
> ///
>
>
>
> _______________________________________________
> 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/bfa7c0a3/attachment.html>
More information about the llvm-commits
mailing list