aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/ADT/SmallSet.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2014-11-24 09:08:18 +0000
committerDimitry Andric <dim@FreeBSD.org>2014-11-24 09:08:18 +0000
commit5ca98fd98791947eba83a1ed3f2c8191ef7afa6c (patch)
treef5944309621cee4fe0976be6f9ac619b7ebfc4c2 /include/llvm/ADT/SmallSet.h
parent68bcb7db193e4bc81430063148253d30a791023e (diff)
Diffstat (limited to 'include/llvm/ADT/SmallSet.h')
-rw-r--r--include/llvm/ADT/SmallSet.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/include/llvm/ADT/SmallSet.h b/include/llvm/ADT/SmallSet.h
index 5dfe924f6d78..bb1971eb7c5d 100644
--- a/include/llvm/ADT/SmallSet.h
+++ b/include/llvm/ADT/SmallSet.h
@@ -37,18 +37,22 @@ class SmallSet {
typedef typename SmallVector<T, N>::const_iterator VIterator;
typedef typename SmallVector<T, N>::iterator mutable_iterator;
public:
+ typedef size_t size_type;
SmallSet() {}
- bool empty() const { return Vector.empty() && Set.empty(); }
- unsigned size() const {
+ bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const {
+ return Vector.empty() && Set.empty();
+ }
+
+ size_type size() const {
return isSmall() ? Vector.size() : Set.size();
}
- /// count - Return true if the element is in the set.
- bool count(const T &V) const {
+ /// count - Return 1 if the element is in the set, 0 otherwise.
+ size_type count(const T &V) const {
if (isSmall()) {
// Since the collection is small, just do a linear search.
- return vfind(V) != Vector.end();
+ return vfind(V) == Vector.end() ? 0 : 1;
} else {
return Set.count(V);
}