tagged [dictionary]

How to convert IEnumerable of KeyValuePair<x, y> to Dictionary?

How to convert IEnumerable of KeyValuePair to Dictionary? Is there streamlined way to convert list/enumberable of `KeyValuePair` to `Dictionary`? Linq transformation, .ToDictionary() extension did not...

4 Jan at 09:29

Dictionary enumeration in C#

Dictionary enumeration in C# How do I enumerate a dictionary? Suppose I use `foreach()` for dictionay enumeration. I can't update a key/value pair inside `foreach()`. So I want some other method.

19 Dec at 11:30

How the Dictionary is internally maintained?

How the Dictionary is internally maintained? When i say is it equivalent to two different arrays such as:

21 Oct at 12:49

What happens to C# Dictionary<int, int> lookup if the key does not exist?

What happens to C# Dictionary lookup if the key does not exist? I tried checking for null but the compiler warns that this condition will never occur. What should I be looking for?

26 Jan at 11:17

C# Dictionary, 2 Values

C# Dictionary, 2 Values What would be the best C# data structure for using one key, and having two values pulled out? Essentially I need a `Dictionary`. Is there something like this?

19 Apr at 14:34

Convert JSONObject to Map

Convert JSONObject to Map I have a `JSONObject` with some attributes that I want to convert into a `Map` Is there something that I can use from the json.org or `ObjectMapper`?

4 Feb at 05:54

How to combine two dictionaries without looping?

How to combine two dictionaries without looping? I have two dictionaries of type `` in C#. How can I copy all the contents of one Dictionary object to the other without applying a loop?

29 Apr at 14:5

How to define hash tables in Bash?

How to define hash tables in Bash? What is the equivalent of [Python dictionaries](https://docs.python.org/2/tutorial/datastructures.html#dictionaries) but in Bash (should work across OS X and Linux).

Dictionaries and default values

Dictionaries and default values Assuming `connectionDetails` is a Python dictionary, what's the best, most elegant, most "pythonic" way of refactoring code like this?

6 Jan at 03:35

C# linq in Dictionary<>

C# linq in Dictionary I have an object `allStudents = Dictionary>()` In Linq how would I get a list of all the students who are male? (student.Gender=="m") from all the Classrooms? Ian

31 Mar at 11:50

How to sort a map by value in JavaScript?

How to sort a map by value in JavaScript? How to sort this map by value?

18 Sep at 08:16

Reverse Sorted Dictionary in .NET

Reverse Sorted Dictionary in .NET Is there any way I can iterate backwards (in reverse) through a SortedDictionary in c#? Or is there a way to define the SortedDictionary in descending order to begin ...

11 Jun at 10:17

Most elegant way to convert string array into a dictionary of strings

Most elegant way to convert string array into a dictionary of strings Is there a built-in function for converting a string array into a dictionary of strings or do you need to do a loop here?

9 Jul at 06:28

How to index into a dictionary?

How to index into a dictionary? I have a Dictionary below: How do I index the first entry in the dictionary? `colors[0]` will return a `KeyError` for obvious reasons.

7 Jun at 01:41

How can I convert a ConcurrentDictionary to a Dictionary?

How can I convert a ConcurrentDictionary to a Dictionary? I have a ConcurrentDictionary object that I would like to set to a Dictionary object. Casting between them is not allowed. So how do I do it?

Search a list of dictionaries in Python

Search a list of dictionaries in Python Given: How do I search by `name == "Pam"` to retrieve the corresponding dictionary below?

28 Feb at 07:4

finding difference between two dictionaries

finding difference between two dictionaries Is there a LINQ method to find difference between two generic dictionaries? Same as in [this question](https://stackoverflow.com/questions/6007495/differenc...

23 May at 12:25

Map with Key as String and Value as List in Groovy

Map with Key as String and Value as List in Groovy Can anyone point me to an example of how to use a `Map` in Groovy which has a `String` as its key and a `List` as value?

4 Sep at 17:10

Are ValueTuples suitable as dictionary keys?

Are ValueTuples suitable as dictionary keys? I'm thinking this could be a convenient dictionary: What would the hashes look like? What would the equivalent key type (struct) look like?

18 Dec at 10:31

map vs. hash_map in C++

map vs. hash_map in C++ I have a question with `hash_map` and `map` in C++. I understand that `map` is in STL, but `hash_map` is not a standard. What's the difference between the two?

29 Sep at 14:21

Is there anyway to handy convert a dictionary to String?

Is there anyway to handy convert a dictionary to String? I found the default implemtation of ToString in the dictionary is not what I want. I would like to have `{key=value, ***}`. Any handy way to ge...

21 Jan at 13:5

How do I copy the content of a dictionary to an new dictionary in C#?

How do I copy the content of a dictionary to an new dictionary in C#? How can I copy a `Dictionary` to another `new Dictionary` so that they are not the same object?

11 May at 11:8

Creating a new dictionary in Python

Creating a new dictionary in Python I want to build a dictionary in Python. However, all the examples that I see are instantiating a dictionary from a list, etc . .. How do I create a new empty dictio...

4 Feb at 17:3

Should I use 'has_key()' or 'in' on Python dicts?

Should I use 'has_key()' or 'in' on Python dicts? Given: Which of the following is the best way to check if `'a'` is in `d`?

10 Apr at 12:20

How to copy a dictionary and only edit the copy

How to copy a dictionary and only edit the copy I set `dict2 = dict1`. When I edit `dict2`, the original `dict1` also changes. Why?

10 Apr at 10:46