Namespaces
Variants
Actions

Talk:cpp/container/map/map

From cppreference.com
< Talk:cpp‎ | container‎ | map

"Complexity" says that the iterator constructor is linear. It's only linear if the elements are already ordered, otherwise it's N log N.

I think the fix is to edit the template that this comes from (http://en.cppreference.com/w/Template:cpp/container/constructor_ord), since the same is true for all associative containers. 81.110.180.57 06:07, 19 March 2013 (PDT)

Fixed, thanks! P12 12:50, 19 March 2013 (PDT)


I'm glad for this info, but less happy with the comma "array-of-three chars" implementation, wouldn't it be cleaner just to use a bool isFirst flag and then at the top of the loop do 'if (!first) cout << ", ";' ? 86.91.208.67 04:30, 11 July 2015 (PDT)

[edit] Compare() missing in default constructor

Dear C++ experts, I'm not sure about it but I feel that a " = Compare()" might be missing in the first default map constructor. Greetings. 84.147.15.106 04:38, 1 May 2018 (PDT)

No. Constructing with a Compare object is handled by the 2nd constructor. --LittleFlower (talk) 02:00, 2 May 2018 (PDT)
Sorry for my unclear statement. I didn't mean the very first constructor "map();" but the 2nd one "explicit map( const Compare& comp," which in my feeling should read "explicit map( const Compare& comp = Compare(),".
I think you're confused by the description calling (1) a "default constructor", It should just say "creates an empty container", since that's what all three of them do (one taking no args, one taking comparator, and one taking allocator) --Cubbi (talk) 03:40, 2 May 2018 (PDT)
Yes, I think this is what I meant since a "default constructor" is called without arguments. And I tried to ensure this by providing a full set of default arguments. Thank you.