[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


>unordered_map<int, int> A;
>if (A.find(42) != A.end())

>A = {}
>if 42 in A

why is C++ so cucked compared to python?
>>
>>108361606
No clue, I just use AI
>>
>>108361606
>A = {}
not an unordered map since Python 3.7
>>
>>108361606
>unordered_map<int, int> A;
you can drop the template parameters if the compiler can deduce them, e.g.
unordered_map A {{1, 10}, {2, 20}};

>if (A.find(42) != A.end())
if(A.contains(42))

it's been in the language for 6 years now
>>
>>108361723
>not possible in c++17
>>
>>108361723
>contains
buddy we're still on C++17 here
>>
>>108361773
usecase for using outdated C++ standards?
>>
>>108361773
>>108361792
skill issue, everything in c++20 but memedules has been implemented in all 3 major compilers for years
>>
>>108361606
>the users of Guido's slow webshit language are beefing with the users of Bjarne's fast schizophrenia language
Cute. Have you read your SICP today?
>>
>>108361802
employment
>>108361816
see above. strict C++17 compliance until we increment the whole stack.
>>
>>108361606
find returns the iterator so you can also get the element. Not really seeing the problem here. Similar to rust hashmaps returning a Option<V> for #get.
>>
File: 1773408042909147.png (63 KB, 1214x350)
63 KB
63 KB PNG
>>108361832
>>
It’s the consequence of trying to improve an already perfect language
>>
>>108361946
op is mad that you have to manually write the ".contains()" implementation every time
>>
>>108361946
and what if you don't need the element?
>>
>>108361773
>17
holy unc
>>
>>108362832
some people work for their own keep rather than leeching off mommy
>>
>>108361606
Different priorities. People with other use cases are asking why Python is so cucked compared to C++, being 50-200x slower or smth.
>>
>>108361606
>if 42 in A

if 42 in A what?
>>
>>108361914
Must be a shitty fucking company then. I bet they also use java 8.
>>
>>108362820
when the fuck would you not?
the number of times I needed to see if something was in a hashmap but not get the value has been pretty slim.
>>
that python code is the same as
if a.keys().__contains__(42)

it is just hidden. dont given the c++ committee any ideas.
>>
>>108361606
which is faster?
>>
>>108361606
Why are you looking for a number in an empty map? Are you retarded?
>>
>>108362839
Get a better job, you boomerware janny.
>>
File: 1767821279125721.png (250 KB, 525x384)
250 KB
250 KB PNG
console.log(typeof null);

>object
>>
>>108365317
boomerware still runs c++98
>>
>>108365674
Everything below 20 is boomerware.
>>
>>108361641
It's an insertion-ordered map, which is a different thing, a combination of hash table and linked list. Basically, you can think of it as keeping the hash buckets in a deque as well so that the order is preserved, but the deque isn't used for looking things up by key (as that's what the hash table does). It's a touch more complex than that, but not much and it works really well.
Cost: extra two pointers per entry in the dict (and a little overhead per dict to hold the head and tail pointers).
>>
>>108361606
>>108361633
Indians



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.