llvm.org GIT mirror llvm / 4ef09de
The count() function for STL datatypes returns unsigned, even where it's only bool-like 1/0 result like std::set.count(). Some of the LLVM ADT already return unsigned count(), while others return bool count(). This patch modifies SmallPtrSet, SmallSet, SparseSet count() to return unsigned instead of bool: 1 instead of true 0 instead of false More ADT to follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197879 91177308-0d34-0410-b5e6-96231b3b80d8 Yaron Keren 6 years ago
4 changed file(s) with 12 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
270270 return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
271271 }
272272
273 /// count - Return true if the specified pointer is in the set.
274 bool count(PtrType Ptr) const {
275 return count_imp(PtrTraits::getAsVoidPointer(Ptr));
273 /// count - Return 1 if the specified pointer is in the set, 0 otherwise.
274 unsigned count(PtrType Ptr) const {
275 return count_imp(PtrTraits::getAsVoidPointer(Ptr)) ? 1 : 0;
276276 }
277277
278278 template
4646 return isSmall() ? Vector.size() : Set.size();
4747 }
4848
49 /// count - Return true if the element is in the set.
50 bool count(const T &V) const {
49 /// count - Return 1 if the element is in the set, 0 otherwise.
50 unsigned count(const T &V) const {
5151 if (isSmall()) {
5252 // Since the collection is small, just do a linear search.
53 return vfind(V) != Vector.end();
53 return vfind(V) == Vector.end() ? 0 : 1;
5454 } else {
5555 return Set.count(V);
5656 }
226226 return const_cast(this)->findIndex(KeyIndexOf(Key));
227227 }
228228
229 /// count - Returns true if this set contains an element identified by Key.
230 ///
231 bool count(const KeyT &Key) const {
232 return find(Key) != end();
229 /// count - Returns 1 if this set contains an element identified by Key,
230 /// 0 otherwise.
231 ///
232 unsigned count(const KeyT &Key) const {
233 return find(Key) == end() ? 0 : 1;
233234 }
234235
235236 /// insert - Attempts to insert a new element.
312312 return GetOrCreateValue(Key).getValue();
313313 }
314314
315 /// count - Return 1 if the element is in the map, 0 otherwise.
315316 size_type count(StringRef Key) const {
316317 return find(Key) == end() ? 0 : 1;
317318 }