set< pair<string, string> > or multiset?
From: Mario Contestabile (mario_at_zks.net)
Date: 09/14/04
- Next message: Igor Tandetnik: "Re: set< pair<string, string> > or multiset?"
- Previous message: Tom Widmer: "Re: how to realize a parameters list."
- Next in thread: Igor Tandetnik: "Re: set< pair<string, string> > or multiset?"
- Reply: Igor Tandetnik: "Re: set< pair<string, string> > or multiset?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 14 Sep 2004 09:52:43 -0400
Greetings,
Buddy of mine's code has a set<> (this is with the dinkum library 2.32) and
in it he places a pair<> of strings.
This is what it looks like: set< pair<string, string> >
Since the default comparison function for set is less, as seen here from
<functional>
template<class _Ty>
struct less : binary_function<_Ty, _Ty, bool> {
bool operator()(const _Ty& _X, const _Ty& _Y) const
{return (_X < _Y); }
};
I was wondering just how will his set<> be ordered ? Will it be ordered on
the string comparison for the pair.first or pair.second?
Wouldn't the use of a multiset be better suited? A multiset is for
(possibly) non unique keys, and a set is for unique keys.
The way he has it written, items are inserted into the set like so
x = std::make_pair( strKey, strValue );
hisSet.insert( x );
but strKey is not unique at all, there are several instances of the same
string.
thanx
- Next message: Igor Tandetnik: "Re: set< pair<string, string> > or multiset?"
- Previous message: Tom Widmer: "Re: how to realize a parameters list."
- Next in thread: Igor Tandetnik: "Re: set< pair<string, string> > or multiset?"
- Reply: Igor Tandetnik: "Re: set< pair<string, string> > or multiset?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|