llvm.org GIT mirror llvm / 5e87754
Give SetVector range support git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14855 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 15 years ago
2 changed file(s) with 34 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2727 /// @breif A vector that has set insertion semantics.
2828 template
2929 class SetVector {
30
3130 public:
3231 typedef T value_type;
3332 typedef T key_type;
3837 typedef typename vector_type::iterator iterator;
3938 typedef typename vector_type::const_iterator const_iterator;
4039 typedef typename vector_type::size_type size_type;
40
41 /// @brief Construct an empty SetVector
42 SetVector() {}
43
44 /// @brief Initialize a SetVector with a range of elements
45 template
46 SetVector( It Start, It End ) {
47 insert(Start, End);
48 }
4149
4250 /// @brief Completely clear the SetVector
4351 void clear() {
9098 return result;
9199 }
92100
101 /// @brief Insert a range of elements into the SetVector.
102 template
103 void insert( It Start, It End ) {
104 for (; Start != End; ++Start)
105 if ( set_.insert(*Start).second )
106 vector_.push_back(*Start);
107 }
108
93109 /// @returns 0 if the element is not in the SetVector, 1 if it is.
94110 /// @brief Count the number of elements of a given key in the SetVector.
95111 size_type count( const key_type& key ) const {
2727 /// @breif A vector that has set insertion semantics.
2828 template
2929 class SetVector {
30
3130 public:
3231 typedef T value_type;
3332 typedef T key_type;
3837 typedef typename vector_type::iterator iterator;
3938 typedef typename vector_type::const_iterator const_iterator;
4039 typedef typename vector_type::size_type size_type;
40
41 /// @brief Construct an empty SetVector
42 SetVector() {}
43
44 /// @brief Initialize a SetVector with a range of elements
45 template
46 SetVector( It Start, It End ) {
47 insert(Start, End);
48 }
4149
4250 /// @brief Completely clear the SetVector
4351 void clear() {
9098 return result;
9199 }
92100
101 /// @brief Insert a range of elements into the SetVector.
102 template
103 void insert( It Start, It End ) {
104 for (; Start != End; ++Start)
105 if ( set_.insert(*Start).second )
106 vector_.push_back(*Start);
107 }
108
93109 /// @returns 0 if the element is not in the SetVector, 1 if it is.
94110 /// @brief Count the number of elements of a given key in the SetVector.
95111 size_type count( const key_type& key ) const {