Why is the C++ STL set container's count() method thus named? -


what checks contains() , not count of number of occurrences, right? duplicates not permitted either wouldn't contains() better name count()?

it's make consistent other container classes, given 1 of great aspects of polymorphism able treat different classes same api.

it does return count. fact count can 0 or 1 set not change aspect.

it's not fundamentally different collection object allows 2 things of each "value" @ same time. in case, return count of zero, 1 or two, it's still count, same set.

the relevant part of standard requires c++11 23.2.4 talks associative containers set, multiset, map , multimap. table 102 contains requirements these associative containers on , above requirements "regular" containers, , bit count paraphrased below:

size_type a.count(k) - returns number of elements key equivalent k. complexity log(a.size()) + a.count(k).


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -