Click here to Skip to main content
15,908,768 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Custom CListCtrl Pin
Halloko5-Apr-04 5:48
Halloko5-Apr-04 5:48 
GeneralSad tale of 'const' Pin
73Zeppelin4-Apr-04 0:11
73Zeppelin4-Apr-04 0:11 
GeneralRe: Sad tale of 'const' Pin
Neville Franks4-Apr-04 0:37
Neville Franks4-Apr-04 0:37 
GeneralRe: Sad tale of 'const' Pin
73Zeppelin4-Apr-04 0:40
73Zeppelin4-Apr-04 0:40 
GeneralRe: Sad tale of 'const' Pin
Neville Franks4-Apr-04 1:34
Neville Franks4-Apr-04 1:34 
GeneralRe: Sad tale of 'const' Pin
Jörgen Sigvardsson4-Apr-04 9:04
Jörgen Sigvardsson4-Apr-04 9:04 
Generalspecifying a map Pin
MatthewP3-Apr-04 22:43
MatthewP3-Apr-04 22:43 
GeneralRe: specifying a map Pin
Andrew Walker3-Apr-04 23:52
Andrew Walker3-Apr-04 23:52 
Just as a reference for the comments below, from the Microsoft Documentation:

template <
class Key,
class Type,
class Traits = less<Key>,
class Allocator=allocator<pair <const Key, Type> >
>

MatthewP wrote:
how the predicate 'op' differs in each map example below

The comparison of keys defaults to using std::less<Key>, which relies upon a less than operator being available. In examples 1) and 3) a custom comparison functor needs to be supplied. In 2) the default is used.

MatthewP wrote:
why op needs to be a class or struct with the predicate specified in an overloaded () operator

It doesn't. All it needs to do is provide function call notation, it could be a function, but is generally implemented as a class or struct.

MatthewP wrote:
why when I use #2 or #3 I loose the ability to change an element using map[key] (such as ++map[key])

From the Microsoft Documentation:

Type& operator[](
const Key& _Key
);

You can, you just need to make sure that the types of the template paramters match the types of the comparison functor.

MatthewP wrote:
if it is possible to order the elements based on the elements(elem) themselves

If this is a problem perhaps a map isn't the appropriate data structure. Sometimes sorted or associative vectors (or even sets) may give better performance or model the problem domain more closely.

Look at the common operations (in performance critical code) that you'll be using the container for, and select the container based upon those operation. Are inserts, removes or updates the most frequent operations? Most operations are cited in big oh notation, and are easy to get.


If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.

Rudyard Kipling

Generalmap container Pin
MatthewP3-Apr-04 22:41
MatthewP3-Apr-04 22:41 
GeneralRe: map container Pin
Johnny ²3-Apr-04 23:45
Johnny ²3-Apr-04 23:45 
Generalapp not compatable between XP and 2000 Pin
quzi3-Apr-04 21:50
quzi3-Apr-04 21:50 
GeneralRe: app not compatable between XP and 2000 Pin
Alexander M.,4-Apr-04 1:03
Alexander M.,4-Apr-04 1:03 
GeneralRe: app not compatable between XP and 2000 Pin
quzi4-Apr-04 1:25
quzi4-Apr-04 1:25 
QuestionHow to create an ActiveX in Visual Studio? Pin
anderslundsgard3-Apr-04 21:48
anderslundsgard3-Apr-04 21:48 
GeneralQuestion on serial port and data buffer Pin
knightri3-Apr-04 17:11
knightri3-Apr-04 17:11 
GeneralRe: Question on serial port and data buffer Pin
Simon.W3-Apr-04 17:21
Simon.W3-Apr-04 17:21 
GeneralRe: Question on serial port and data buffer Pin
knightri4-Apr-04 10:29
knightri4-Apr-04 10:29 
GeneralRe: Question on serial port and data buffer Pin
Simon.W5-Apr-04 1:14
Simon.W5-Apr-04 1:14 
GeneralRe: Question on serial port and data buffer Pin
Paul Ranson4-Apr-04 13:01
Paul Ranson4-Apr-04 13:01 
GeneralData Type from Serial Port Pin
CNewbie3-Apr-04 12:47
CNewbie3-Apr-04 12:47 
GeneralRe: Data Type from Serial Port Pin
Orkun GEDiK3-Apr-04 12:54
Orkun GEDiK3-Apr-04 12:54 
GeneralRe: Data Type from Serial Port Pin
CNewbie3-Apr-04 12:56
CNewbie3-Apr-04 12:56 
GeneralRe: Data Type from Serial Port Pin
Orkun GEDiK3-Apr-04 13:02
Orkun GEDiK3-Apr-04 13:02 
GeneralRe: Data Type from Serial Port Pin
Paul Ranson4-Apr-04 12:34
Paul Ranson4-Apr-04 12:34 
GeneralRe: Data Type from Serial Port Pin
CNewbie4-Apr-04 13:50
CNewbie4-Apr-04 13:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.