The count() function for STL datatypes returns unsigned, even where it's

only 1/0 result like std::set. Some of the LLVM ADT already return unsigned
count(), while others still return bool count().

In continuation to r197879, this patch modifies DenseMap, DenseSet, 
ScopedHashTable, ValueMap:: count() to return size_type instead of bool,
1 instead of true and 0 instead of false.

size_type is typedef-ed locally within each class to size_t.

http://reviews.llvm.org/D4018

Reviewed by dblaikie.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211350 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Yaron Keren
2014-06-20 10:26:56 +00:00
parent e5241cc488
commit ed4e8a839f
14 changed files with 42 additions and 29 deletions

View File

@@ -43,6 +43,7 @@ protected:
typedef std::pair<KeyT, ValueT> BucketT;
public:
typedef size_t size_type;
typedef KeyT key_type;
typedef ValueT mapped_type;
typedef BucketT value_type;
@@ -70,7 +71,7 @@ public:
unsigned size() const { return getNumEntries(); }
/// Grow the densemap so that it has at least Size buckets. Does not shrink
void resize(size_t Size) {
void resize(size_type Size) {
if (Size > getNumBuckets())
grow(Size);
}
@@ -99,10 +100,10 @@ public:
setNumTombstones(0);
}
/// count - Return true if the specified key is in the map.
bool count(const KeyT &Val) const {
/// Return 1 if the specified key is in the map, 0 otherwise.
size_type count(const KeyT &Val) const {
const BucketT *TheBucket;
return LookupBucketFor(Val, TheBucket);
return LookupBucketFor(Val, TheBucket) ? 1 : 0;
}
iterator find(const KeyT &Val) {