Tag: dictionary

56 votes
4 answers
1.1K views
Convert Linq Query Result to Dictionary

I want to add some rows to a database using Linq to SQL, but I want to make a "custom check" before adding the

avatar
Kurtis
0 1 0 9
asked 07 September, 2021
58 votes
16 answers
506 views
54 votes
20 answers
1.4K views
How can I add new keys to a dictionary?

Is it possible to add a key to a Python dictionary after it has been created? It doesn't seem to have an

avatar
Venice
0 1 0 9
asked 07 September, 2021
64 votes
30 answers
720 views
57 votes
14 answers
1.9K views
Iterating over dictionaries using 'for' loops

I am a bit puzzled by the following code: d = {'x': 1, 'y': 2, 'z': 3} for key

avatar
Hilario
0 1 0 9
asked 07 September, 2021
59 votes
30 answers
2.5K views
How do I merge two dictionaries in a single expression (taking union of dictionaries)?

I have two Python dictionaries, and I want to write a single expression that returns these two dictionaries, m

avatar
Thurman
0 1 0 9
asked 07 September, 2021
60 votes
6 answers
2.1K views
Why is std::map implemented as a red-black tree?

Why is std::map implemented as a red-black tree? There are several balanced binary search trees (BSTs) out th

avatar
Venice
0 1 0 9
asked 07 September, 2021
51 votes
21 answers
1K views
What is the best way to implement nested dictionaries?

I have a data structure which essentially amounts to a nested dictionary. Let's say it looks like this:

avatar
Boyd
0 1 0 9
asked 07 September, 2021
61 votes
12 answers
455 views
What is the difference between a map and a dictionary?

I know a map is a data structure that maps keys to values. Isn't a dictionary the same? What is the diffe

avatar
Thurman
0 1 0 9
asked 07 September, 2021
55 votes
11 answers
1.4K views
Does VBA have Dictionary Structure?

Does VBA have dictionary structure? Like key<>value array?

avatar
Xavier
0 1 0 9
asked 07 September, 2021
65 votes
12 answers
1.3K views
In Python, when to use a Dictionary, List or Set?

When should I use a dictionary, list or set? Are there scenarios that are more suited for each data type?

avatar
Ali
0 1 0 9
asked 07 September, 2021
60 votes
3 answers
458 views
How are Python&apos;s Built In Dictionaries Implemented?

Does anyone know how the built in dictionary type for python is implemented? My understanding is that it is s

avatar
Juliane
0 1 0 9
asked 07 September, 2021
63 votes
13 answers
2.8K views
How can I remove a key from a Python dictionary?

When deleting a key from a dictionary, I use: if 'key' in my_dict: del my_dict['key']

avatar
Jeff
0 1 0 9
asked 07 September, 2021
60 votes
18 answers
1K views
How do I sort a list of dictionaries by a value of the dictionary?

I have a list of dictionaries and want each item to be sorted by a specific value. Take into consideration the

avatar
Nereida
0 1 0 9
asked 07 September, 2021
51 votes
30 answers
704 views
Sort a Map<Key, Value> by values

I am relatively new to Java, and often find that I need to sort a Map<Key, Value> on the values. Since

avatar
Adolfo
0 1 0 9
asked 07 September, 2021
67 votes
30 answers
833 views
How do I efficiently iterate over each entry in a Java Map?

If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained wit

avatar
Daniel
0 1 0 9
asked 07 September, 2021