aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/SparseSet.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ADT/SparseSet.h')
-rw-r--r--include/llvm/ADT/SparseSet.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/include/llvm/ADT/SparseSet.h b/include/llvm/ADT/SparseSet.h
index 267a340..b46ccc9 100644
--- a/include/llvm/ADT/SparseSet.h
+++ b/include/llvm/ADT/SparseSet.h
@@ -118,6 +118,10 @@ template<typename ValueT,
typename KeyFunctorT = llvm::identity<unsigned>,
typename SparseT = uint8_t>
class SparseSet {
+ static_assert(std::numeric_limits<SparseT>::is_integer &&
+ !std::numeric_limits<SparseT>::is_signed,
+ "SparseT must be an unsigned integer type");
+
typedef typename KeyFunctorT::argument_type KeyT;
typedef SmallVector<ValueT, 8> DenseT;
DenseT Dense;
@@ -198,9 +202,6 @@ public:
///
iterator findIndex(unsigned Idx) {
assert(Idx < Universe && "Key out of range");
- assert(std::numeric_limits<SparseT>::is_integer &&
- !std::numeric_limits<SparseT>::is_signed &&
- "SparseT must be an unsigned integer type");
const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
for (unsigned i = Sparse[Idx], e = size(); i < e; i += Stride) {
const unsigned FoundIdx = ValIndexOf(Dense[i]);
@@ -227,10 +228,11 @@ public:
return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
}
- /// count - Returns true if this set contains an element identified by Key.
+ /// count - Returns 1 if this set contains an element identified by Key,
+ /// 0 otherwise.
///
- bool count(const KeyT &Key) const {
- return find(Key) != end();
+ unsigned count(const KeyT &Key) const {
+ return find(Key) == end() ? 0 : 1;
}
/// insert - Attempts to insert a new element.