llvm.org GIT mirror llvm / 5fcaf3e
Make SmallSetVector useful git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33854 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
1 changed file(s) with 5 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
3131 /// order of insertion.
3232 /// @brief A vector that has set insertion semantics.
3333 template ,
34 typename Set = std::set> >
34 typename Set = SmallSet> >
3535 class SetVector {
3636 public:
3737 typedef T value_type;
9898 /// @returns true iff the element was inserted into the SetVector.
9999 /// @brief Insert a new element into the SetVector.
100100 bool insert(const value_type &X) {
101 bool result = set_.insert(X).second;
101 bool result = set_.insert(X);
102102 if (result)
103103 vector_.push_back(X);
104104 return result;
108108 template
109109 void insert(It Start, It End) {
110110 for (; Start != End; ++Start)
111 if (set_.insert(*Start).second)
111 if (set_.insert(*Start))
112112 vector_.push_back(*Start);
113113 }
114114
115115 /// @brief Remove an item from the set vector.
116116 void remove(const value_type& X) {
117 if (0 < set_.erase(X)) {
117 if (set_.erase(X)) {
118118 typename vector_type::iterator I =
119119 std::find(vector_.begin(), vector_.end(), X);
120120 assert(I != vector_.end() && "Corrupted SetVector instances!");
151151 /// a certain size.
152152 template
153153 class SmallSetVector : public SetVector, SmallSet > {
154 public:
154155 SmallSetVector() {}
155156
156157 /// @brief Initialize a SmallSetVector with a range of elements