dictionary

.NET Dictionary: Potential concurrency problems?

Hi all. I'm working on maintenance of a .NET project, and I'm having some troubles which I'll gladly share with you guys =) The problem code: if( evilDict.Count < 1 ) { foreach (Item item in GetAnotherDict()) if (!evilDict.containsKey(item.name.ToLower().Trim())) evilDict.add(item.name.ToLower().Trim(), item.ID)...

Serialize Class containing Dictionary member

Expanding upon my earlier problem, I've decided to (de)serialize my ConfigFile class which worked great. I now want to store an associative array of drive letters to map (key is the drive letter, value is the network path) and have tried using Dictionary, HybridDictionary, and Hashtable for this but I always get the following error when ...

Generics List with Array return but how ?

These Codes really boring. And Tostring() give me error !!! Can you rearrange these codes ? class Program { static void Main(string[] args) { string[] arraystr = { "yusuf", "mehmet" }; Ilist myitems = new Ilist(arraystr); SelectedItemsList slist = new SelectedItemsList(); ...

.NET Dictionary: is only enumerating thread safe?

Is simply enumerating a .NET Dictionary from multiple threads safe? No modification of the Dictionary takes place at all. ...

Why is python ordering my dictionary like so?

Here is the dictionary I have propertyList = { "id": "int", "name": "char(40)", "team": "int", "realOwner": "int", "x": "int", "y": "int", "description": "char(255)", "port": "bool", "secret": "bool", "dead": "bool", "nomadic": "bool", "population": "int", "slaves": "int", } But when I print it out w...

Is there an IDictionary implementation that returns null on missing key instead of throwing?

The indexer into Dictionary throws an exception if the key is missing. Is there an implementation of IDictionary that instead will return default(T)? I know about the "TryGetValue" method, but that's impossible to use with linq. Would this efficiently do what I need?: myDict.FirstOrDefault(a => a.Key == someKeyKalue); I don't think...

XML Parsing with C#?

I'm working on a project for school that involves a heavy amount of XML Parsing. I'm coding in C#, but I have yet to find a "suitable" method of parsing this XML out. There's several different ways I've looked at, but haven't gotten it right yet; so I have come to you. Ideally, I'm looking for something kind of similar to Beautiful Soup ...

C# ComboBox Data-Bind Filter

I have a small problem. I have a set of ComboBox's that are bound to lists which are associated with a set of dictionaries that provide int values for a math equation. I need to filter the result of cb_test_2 based on the selection of cb_test_1. I think I am close. What happens when I change the value in cb_test_1 it applies the correct ...

python, dictionary and int error

I have a very frustrating python problem. In this code fixedKeyStringInAVar = "SomeKey" def myFunc(a, b): global sleepTime global fixedKeyStringInAVar varMe=int("15") sleepTime[fixedKeyStringInAVar] = varMe*60*1000 #more code Now this works. BUT sometimes when i run this fuction i get TypeError: 'int' object does...

How do I get all the values of a Dictionary<TKey, TValue> as an IList<TValue>?

I have a the following dictionary: IDictionary<int, IList<MyClass>> myDictionary and I am wanting to get all the values in the dictionary as an IList.... Just to add a bit of a background as to how I've gotten into this situation.... I have a method that gets me a list of MyClass. I then have another method that converts that list...

Scripting.Dictionary access methods?

Is there anyway to access intercept when an item gets added to a Scripting.Dictionary or hook up an event in javascript?? Do they have accessor methods eg. set, get or not? var test = new ActiveXObject("Scripting.Dictionary"); test("a") = "test"; I need to do some more tasks when this is set. Any help would be greatly appreciated. ...

Dictionary / List of words

What is the biggest / largest / best list of words in the English language? Something in a simple text file would be great. ...

Bijective Dictionary /Map in C#

Is there a bijective dictionary in.NET that efficiently stores Key/Values pairs, where both keys and values are distinct, so a bijective mapping (i.e. TryGetValue/TryGetKey) is possible? The naive approach would be to have two internal dictionaries: A key-value and a value-key dictionary, but this is not efficient in terms of memory. ...

Putting spaces back into a string of text with unreliable space information

I need to parse some text from pdfs but the pdf formatting results in extremely unreliable spacing. The result is that I have to ignore the spaces and have a continuous stream of non-space characters. Any suggestions on how to parse the string and put spaces back into the string by guessing? I'm using ruby. Or should I say I'musingrub...

C# GUI control for editing a Dictionary

Is there a standard control that lets a user edit the key-value pairs of a String to String Dictionary? If not, how would you implement one? I've got a few ideas but none of them seems great. ...

Python "extend" for a dictionary

Which is the best way to extend a dictionary with another one? For instance: >>> a = { "a" : 1, "b" : 2 } >>> b = { "c" : 3, "d" : 4 } >>> a {'a': 1, 'b': 2} >>> b {'c': 3, 'd': 4} I'm looking for any operation to obtain this avoiding for loop: { "a" : 1, "b" : 2, "c" : 3, "d" : 4 } I wish to do something like: a.extend(b) # This...

Does Dictionary<TKey, TValue> order by the keys by default?

I'm using a Dictionary<TKey, TValue> and I'm getting some odd, though somewhat understandable behaviour in my tests. No matter the order I add entries to the dictionary when I call Dictionary.Keys the keys are returned in the order specified by the IComparable<T> implementation for the key's type. This is good for me as I want to get t...

Where do you put your dictionary data?

Let's say I have a set of Countries in my application. I expect this data to change but not very often. In other words, I do not look at this set as an operational data (I would not provide CRUD operations for Country, for example). That said I have to store this data somewhere. I see two ways to do that: Database driven. Create and p...

Problems with binary deserialization - can anyone help?

I have the same issue as in this post: http://social.microsoft.com/Forums/en-US/netfxbcl/thread/10027dd8-da47-4691-91a6-a8b89a7f514a Anyone know a possible answer / solution? Funny thing is that I have 2 collections in my serializable class (binary serialization). One is List, one is Dictionary. The List collection is OK, Dictionary re...

How can you print a variable name in python?

Say I have a variable named choice it is equal to 2. How would I access the name of the variable? Something equivalent to In [53]: namestr(choice) Out[53]: 'choice' for use in making a dictionary. There's a good way to do this and I'm just missing it. EDIT: The reason to do this is thus. I am running some data analysis stuff where I...