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,6 +224,20 @@ 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_; } @@ -226,6 +246,11 @@ 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. ///