llvm.org GIT mirror llvm / 337cde0
Convert SetVector to be a true adapter class and add SmallSetVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33846 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
1 changed file(s) with 22 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
1111 // visited later but in a deterministic order (insertion order). The interface
1212 // is purposefully minimal.
1313 //
14 // This file defines SetVector and SmallSetVector, which performs no allocations
15 // if the SetVector has less than a certain number of elements.
16 //
1417 //===----------------------------------------------------------------------===//
1518
1619 #ifndef LLVM_ADT_SETVECTOR_H
1720 #define LLVM_ADT_SETVECTOR_H
1821
19 #include
22 #include "llvm/ADT/SmallSet.h"
2023 #include
2124 #include
2225 #include
2326
2427 namespace llvm {
2528
26 /// This class provides a way to keep a set of things that also has the
29 /// This adapter class provides a way to keep a set of things that also has the
2730 /// property of a deterministic iteration order. The order of iteration is the
2831 /// order of insertion.
2932 /// @brief A vector that has set insertion semantics.
30 template >
33 template , typename Vector = std::vector,
34 typename Set = std::set >
3135 class SetVector {
3236 public:
3337 typedef T value_type;
3438 typedef T key_type;
3539 typedef T& reference;
3640 typedef const T& const_reference;
37 typedef std::set set_type;
38 typedef std::vector vector_type;
41 typedef Set set_type;
42 typedef Vector vector_type;
3943 typedef typename vector_type::const_iterator iterator;
4044 typedef typename vector_type::const_iterator const_iterator;
4145 typedef typename vector_type::size_type size_type;
143147 vector_type vector_; ///< The vector.
144148 };
145149
150 /// SmallSetVector - A SetVector that performs no allocations if smaller than
151 /// a certain size.
152 template
153 class SmallSetVector : public SetVector, SmallSet > {
154 SmallSetVector() {}
155
156 /// @brief Initialize a SmallSetVector with a range of elements
157 template
158 SmallSetVector(It Start, It End) {
159 this->insert(Start, End);
160 }
161 };
162
146163 } // End llvm namespace
147164
148165 // vim: sw=2 ai