//===- llvm/ADT/SetVector.h - Set with insert order iteration ---*- C++ -*-===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by Reid Spencer and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
-// This file implements a set that has insertion order iteration
+// This file implements a set that has insertion order iteration
// characteristics. This is useful for keeping a set of things that need to be
// visited later but in a deterministic order (insertion order). The interface
// is purposefully minimal.
#include <set>
#include <vector>
#include <cassert>
+#include <algorithm>
namespace llvm {
-/// This class provides a way to keep a set of things that also has the
+/// This class provides a way to keep a set of things that also has the
/// property of a deterministic iteration order. The order of iteration is the
/// order of insertion.
/// @brief A vector that has set insertion semantics.
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 = std::find(vector_.begin(),vector_.end(),X);
+ assert(I != vector_.end() && "Corrupted SetVector instances!");
+ 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 {