dictionary

iPhone .string files

Can someone explain to me how .string files can be used in iPhone SDK similar to how .plist files can be converted into NSDictionaries? Edit: I want to be able to use it like this: NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:@"dict.plist"]; NS???? *strings = [[NS???? alloc] initWithContentsOfFile:@"Strings.strin...

Transforming Dictionary<T,U> to Dictionary<T, U.PropertyValue>

I'm in the process of re-writing some code whilst maintaining the external interface. The method I now need to work on has the following signature: public Dictionary<int, string> GetClientIdNames() This originally directly returned a backing field, after verifying that it was populating it and doing so if required. There's now a requi...

Is there a collection in .NET that works as a dictionary and list at the same time?

What I want is basically a collection that's a hybrid of a dictionary and a list. I want a collection that I can add key/value pairs to (like a Dictionary), but at the same be able to retrieve the values (without the keys) in the same order I added them (like a List)? Does such a collection exists in .NET? Thanks ...

C# Serialize Dictionary<ulong,ulong> to JSON

I am trying to serialize a Dictionary to JSON, and get the following exception: new JavaScriptSerializer().Serialize(mydict) Type 'System.Collections.Generic.Dictionary2[[System.UInt64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Nullable1[[System.UInt64, mscorlib, Version=2.0.0.0, Culture=neut...

ROR: i18n best practices for large translation dictionaries

When internationalizing a rails app, what is the best practice way for organizing/scoping translations in the dictionary files? Under what circumstance should you use interpolations of variables? Should every phrase be it's entry? Is there anyone who participated in dhh's tolk who can shed some light on how 37signals broke up their d...

Random word selection

Is there a way to get a random word from an online dictionary like dictionary.com, into a string for use in PHP. API's etc... Impossible or not? ...

Rename dictionary keys/values in python

What I'm trying to do is this. I have a dictionary laid out as such: legJointConnectors = {'L_hip_jnt': ['L_knee_jnt'], 'L_knee_jnt': ['L_ankle_jnt'], 'L_ankle_jnt': ['L_ball_jnt'], 'L_ball_jnt': ['L_toe_jnt']} What I want to be able to do is iterate through this, but change the L_ to R_. Here's how I tried to do it, but it failed, be...

Reversing Dictionary using LINQ in C#

How to convert Dictioanry<String,List<String>> into Dictionary<String,String> i'm having a dictionary like Dictioanry<String,List<String>>dictOne=new Dictionary<String,List<String>>(); and which containg Key(String) Value(List<String>) A a1,a2 B b1,b2 C c1 i ...

Get the subdictionary based on range

Hi, I have a dictionary which has coordinate pairs as a keys: i.e.: d = {(15,21): "value1", (7,45): "value2", (500,321): "value3",...} Now I need to return a sub dictionary of the elements where the keys are within a certain range: for example: the range of (6:16, 20:46) should return the following dictionary: d = {(15,21): "Value1",...

Without using database how Can I Search for a word and display it's related content in another field

So the question can be reformatted as "What can replace a database in an offline version?" The initial idea is inspired from wordweb where you just type the word and then you get the meaning of it displayed in a fraction. Of-course they are not saving all the words and there meanings in a database. What are they using? Are they storing...

Python: `key not in my_dict` but `key in my_dict.keys()`

I have a weird situation. I have a dict, self.containing_dict. Using the debug probe, I see that dict's contents and I can see that self is a key of it. But look at this: >>> self in self.containing_dict False >>> self in self.containing_dict.keys() True >>> self.containing_dict.has_key(self) False What's going on? (I will note that ...

Need to remove duplicates from a list of dictionaries and alter data for the remaining duplicate (python)

Consider this short python list of dictionaries (first dictionary item is a string, second item is a Widget object): raw_results = [{'src': 'tag', 'widget': <Widget: to complete a form today>}, # dupe 1a {'src': 'tag', 'widget': <Widget: a newspaper>}, # dupe 2a {'src': 'zip', 'widget': <Widget: to co...

Combined "Check Add or Fetch" from Dictionary

I'm tired of this dictionary idiom: Dictionary<Guid,Contact> Contacts; //... if (!Contacts.ContainsKey(id)) { contact = new Contact(); Contacts[id] = contact; } else { contact = Contacts[id]; } It would be nice if there was a syntax tha...

How to bind and retrieve information in a dictionnary<Tkey, TValue> to a ComboBox?

Hello all, I am able to bind a "MyDictionary.Value" to a ComboBox and see the Values in it: Dictionary<string, Friends> friend_list = new Dictionary<string, Friends>(); Friend_chat_list.ItemsSource = friend_list.Values; And here is the XAML code: <ComboBox x:Name="Friend_chat_list" Width="90" ItemsSource="{Binding}" SelectionChanged...

Using Dictionary

Hi, I need to write a script which merges a list with a dictionary to create a third dictionary. I'm pretty new to programming and am struggling with the basics here. So far I've created the following class which generates a list of dates. I have another class which generates a dictionary and I want to basically create a third dictiona...

Is there a way to compare two list of dicts in python?

I have a 2 list of dictionaries. The first list contains sphere definitions in terms of x, y, z, radius. The second list contains various points in space as x, y, z. These lists are both very long, so iterating over each list and compare against all values is inefficient. I've been trying the map and reduce terms, but both of them take...

Access List from another class

Hi, can anyone tell me how to create a list in one class and access it from another? ...

Applying conditions to dictionary key values while traversing through them

The Dictionary is as given below: goodDay= {'Class':[1,1,0,0,0,1,0,1,0,1], 'Grade':[1,0,0,1,0,1,0,1,0,1]} I want to code this way that i should get the count of "1" and also "0" in Class when my grade has value "1" and also vice versa i.e. when my grade has value "0". So i will have to traverse through the list values for both and ...

[Python] Pre declared dictionary size limit?

I have a big dictionary i constantly reference in my code so i have it initialized at the top: import ... myDictionary = {'a':'avalue','b':'bvalue',...} code ... But when i try to get values, some of the keys are not found. It appears as though Python is chopping my dictionary due to a size limit. I tried searching google but could...

Query a Dictionary of Dictionaries?

Hello, Please can you advise me on how to query a Dictionary of Dictionaries, and/or a Dictionary of List? private Dictionary<string, Dictionary<DateTime, double>> masterDict= new Dictionary<string, Dictionary<DateTime, double>>(); Private Dictionary<string, List<DateTime>> masterList= new Dictionary<string, List<DateTime>>(); I know...