Hi,

STL map's comparison functor expects one that returns a bool.

struct strCmp {
    bool operator()( const char* s1, const char* s2 ) const {
      return strcmp( s1, s2 ) > 0;
    }
  };


Can somebody explain how the comparison function is used (independant
of the searching algorithm) work?
eg. there are "a", "b", "c", "d" in the map and we want to know
whether "c" exists.
Let's say a linear search is done.

Here is what I can think of:
1. "c" > "a" : go to next
2. "c" > "b" : go to next
3. "c" <= "c" : what to do from here
4. "c" <= "d" : what to do from here

since strCmp returns > and <= cases how can the matching one be found?
I would have expected a functor returning an int 
(-1, 0, 1) for <, ==, > cases.

Thanks in advance


Reply via email to