1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Give SetVector range support

llvm-svn: 14855
This commit is contained in:
Chris Lattner 2004-07-15 08:18:31 +00:00
parent 36f2a4eb77
commit 1f83f10da7

View File

@ -28,7 +28,6 @@ namespace llvm {
/// @breif A vector that has set insertion semantics.
template <typename T>
class SetVector {
public:
typedef T value_type;
typedef T key_type;
@ -40,6 +39,15 @@ public:
typedef typename vector_type::const_iterator const_iterator;
typedef typename vector_type::size_type size_type;
/// @brief Construct an empty SetVector
SetVector() {}
/// @brief Initialize a SetVector with a range of elements
template<typename It>
SetVector( It Start, It End ) {
insert(Start, End);
}
/// @brief Completely clear the SetVector
void clear() {
set_.clear();
@ -91,6 +99,14 @@ public:
return result;
}
/// @brief Insert a range of elements into the SetVector.
template<typename It>
void insert( It Start, It End ) {
for (; Start != End; ++Start)
if ( set_.insert(*Start).second )
vector_.push_back(*Start);
}
/// @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 {