dictionary

What is the difference between a Map and a Dictionary?

What is the difference between a Map and a Dictionary? I am not asking for how they are defined in language X or Y(which seems to be what generally people are asking here on SO), I want to know what is their difference in theory. I know a Map is an object that maps keys to values. Isn't a Dictionary the same? Thanks ...

Approaches to create a nested tree structure of NSDictionaries?

I'm parsing some input which produces a tree structure containing NSDictionary instances on the branches and NSString instance at the nodes. After parsing, the whole structure should be immutable. I feel like I'm jumping through hoops to create the structure and then make sure it's immutable when it's returned from my method. We can p...

Dictionary with Exact Same Keys and Values

Hi All I need something like a Dictionary or a SortedList but i keep getting exceptions thrown when it receives two things that are the same... Is there another way around this? Thanks ...

Settings File as Dictionary with Serialization

This is a three part question. One: Would using a Dictionary<String,Object> be a good way of saving data where it would be Dictionary<Key,Value> as the basis? Two: What would be a better way without using app.settings or xml? Three: How would you serialize this(Or the better solution) into a binary format that is compact and se...

Problems with Json Serialize Dictionary<Enum, Int32>

Hi, whenever i try to serialize the dictionary i get the exception: System.ArgumentException: Type 'System.Collections.Generic.Dictionary`2[[Foo.DictionarySerializationTest+TestEnum, Foo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' ...

Most efficient way to update attribute of one instance

Hi all - I'm creating an arbitrary number of instances (using for loops and ranges). At some event in the future, I need to change an attribute for only one of the instances. What's the best way to do this? Right now, I'm doing the following: 1) Manage the instances in a list. 2) Iterate through the list to find a key value. 3) Once I ...

Dictionary with delegate or switch?

Hi, I am writing a parser, which call some functions dependent on some value. I can implement this logic with simple switch like this switch(some_val) { case 0: func0(); break; case 1: func1(); break; } or with delegates and dictionary like this delegate v...

Python - Checking for membership inside nested dict

heya, This is a followup questions to this one: http://stackoverflow.com/questions/2901422/python-dictreader-skipping-rows-with-missing-columns Turns out I was being silly, and using the wrong ID field. I'm using Python 3.x here, btw. I have a dict of employees, indexed by a string, "directory_id". Each value is a nested dict with e...

Passing a Dictionary to WCF service

I need to pass a Dictionary (with max 20,000 entries) to a WCF service. Can I pass it all by once? void SubmitDictionary(Dictionary<string, MyEntry> val); where MyEntry is : class MyEntry { string Name; long Age; } Is there a configuration for size of the value passed? Or can we pass as large data as this? ...

PHP API for dictionary

Hi, Iam looking for a good PHP web api for Dictionary. ...

Interesting AS3 hash situation. Is it really using strict equality as the documentation says?

AS3 Code: import flash.utils.Dictionary; var num1:Number = Number.NaN; var num2:Number = Math.sqrt(-1); var dic:Dictionary = new Dictionary( true ); trace(num1); //NaN trace(num2); //NaN dic[num1] = "A"; trace( num1 == num2 ); //false trace( num1 === num2 ); //false trace( dic[num1] ); //A trace( dic[num2] ); //A Concerning the key co...

C# Dictionary of arrays

Can I use C# Dictionary on classes like arrays?? Dictionary<double[],double[]> I am afraid that it will not be able to tell when arrays are equal... EDIT: Will the hashing method in the dictionary take well care of arrays? or just hashing their references? ...

What happens under the hood when using array initialization syntax to initialize a Dictionary instance on C#?

Does anyone know what C# compiler does under the hood with the following code? dict = new Dictionary<int, string>() { { 1, "value1" }, { 2, "value2" } } It is not clear to if it creates the KeyValuePair instances and call the Add method, or do something more optimized. Does anyone of you know it? ...

Python: What's a correct and good way to implement __hash__()?

What's a correct and good way to implement __hash__()? I am talking about the function that returns a hashcode that is then used to insert objects into hashtables aka dictionaries. As __hash__() returns an integer and is used for "binning" objects into hashtables I assume that the values of the returned integer should be uniformly dist...

ASP.Net MVC 2 - better ModelBinding for Dictionary<int, int>

Hi, In some special cases you will need a list of textboxes (to deal with n - n associations) whose id is not know before runtime. Something like this : http://screencast.com/t/YjIxNjUyNmU In that particular sample I'm looking to associate a count to some of my 'templates'. in ASP.Net MVC 1 I coded a Dictionary ModelBinder to have a c...

Why doesn't XmlSerializer support Dictionary?

Just curious as to why Dictionary is not supported by XmlSerializer? You can get around it easily enough by using DataContractSerializer and writing the object to a XmlTextWriter, but what are the characteristics of a Dictionary that makes it difficult for a XmlSerializer to deal with considering it's really an array of KeyValuePairs. ...

Pair attribute naming in custom configSections

I'm trying to store a user list in a config file. I've been looking at DictionarySectionHandler and NameValueSectionHandler. I'm not too sure what the difference between these two is, but anyway, neither of them do exactly what I'd like. You can add a custom config section like so: <configSections> <section name="userAges" type="S...

Asp.net Dictionary - Replace hard coded values with database values

I'm trying to implement this tag cloud: http://thetagcloud.codeplex.com/ ...and I need the replace the hard-coded values below with those coming from my database? <%= new TagCloud( new Dictionary<string, int> { {"C#", 58}, {"ASP.NET", 45}, {"VB.NET", 36}, ...

The best way to use dictionary items as we use the advantages of List

I want to get use of dictionary items like I do in List generic class, e.g; foreach(item in ItemList) { item.BlaBla; } But in dictionary there s no chance, like e method above... Dictionary<string, HtmlInputImage> smartPenImageDictionary; I mean I got to know the key item for the dictionary item.. but what I want, I want to trave...

How to print unsorted dictionary in python?

Guys, I have this dict in python; d={} d['b']='beta' d['g']='gamma' d['a']='alpha' when i print the dict; for k,v in d.items(): print k i get this; a b g it seems like python sorts the dict automatically! how can i get the original unsorted list? Gath ...