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 equivalentk
. complexitylog(a.size()) + a.count(k)
.
Comments
Post a Comment