My initial question was: why does in C++ the contains()
function miss in Containers
?
So I looked for an explanation and I found something interesting about why some other function are not implemented in all the Containers
(essentially because of performance issues and convenience).
I know that you can use the find
function from algorithm
library or you can just write your own function with Iterator
, but what I can't understand is why in set
, for example, the contains
function(where it's called find
) is implemented, whereas in vector
or queue
it is not.
It's pretty clear to me too why Container classes does not share a common interface like Collections
do in Java (thanks to this answer) but in this case I can't find the reason why not implement the contains()
function in all the Containers classes (or at least in some like vector
).
Thank you