From 0bdc620c16963908d74db498f79676e558f09e82 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sat, 11 Sep 2004 04:25:58 +0000 Subject: [PATCH] Implement the remove method for deleting entries from the SetVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16283 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/SetVector.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/llvm/ADT/SetVector.h b/include/llvm/ADT/SetVector.h index 6135e532861..8d7382e0563 100644 --- a/include/llvm/ADT/SetVector.h +++ b/include/llvm/ADT/SetVector.h @@ -20,6 +20,7 @@ #include #include #include +#include namespace llvm { @@ -108,6 +109,16 @@ public: vector_.push_back(*Start); } + /// @brief Remove an item from the set vector. + void remove(const value_type& X) { + if (0 < set_.erase(X)) { + iterator I = find(vector_.begin(),vector_.end(),X); + if (I != vector_.end()) + vector_.erase(I); + } + } + + /// @returns 0 if the element is not in the SetVector, 1 if it is. /// @brief Count the number of elements of a given key in the SetVector. size_type count(const key_type &key) const { -- 2.34.1