M
Michael H Lees
Hi all,
As I see it there are two options for checking if for an element with
key 'x' exists in a map m....
1.) if(m.find(x)!=m.end())
or
2.) if(m.count(x))
They both take O(log N) where N is number of elements. Obviously they
both provide different things but which method should you use for just
checking if a key exists? Does it in fact matter? I have seen examples
of both
Thanks
-Mike
As I see it there are two options for checking if for an element with
key 'x' exists in a map m....
1.) if(m.find(x)!=m.end())
or
2.) if(m.count(x))
They both take O(log N) where N is number of elements. Obviously they
both provide different things but which method should you use for just
checking if a key exists? Does it in fact matter? I have seen examples
of both
Thanks
-Mike