dictionary

how to add duplicate keys to dictionary<string,string>

how to add duplicate keys to dictionary i.e i have already added the key,value pair as rollno,1 but i need to add the same parameter to the dictionary,but it is not allowing to add. how to add duplicated keys/repeated key in dictionary . or any other choice.. any idea??? ...

Convert sets to frozensets as values of a dictionary

I have dictionary that is built as part of the initialization of my object. I know that it will not change during the lifetime of the object. The dictionary maps keys to sets. I want to convert all the values from sets to frozensets, to make sure they do not get changed. Currently I do that like this: for key in self.my_dict.iterkeys():...

rename keys in a dictionary

i want to rename the keys of a dictionary are which are ints, and i need them to be ints with leading zeros's so that they sort correctly. for example my keys are like: '1','101','11' and i need them to be: '001','101','011' this is what im doing now, but i know there is a better way tmpDict = {} for oldKey in aDict: tmpDict...

Android Dictionary

Is there a dictionary API for Android. I am mainly looking for simple features like: -- Given a word, look up its meaning -- Look up all words that begin with "cat" Thanks Chris ...

How do I implement a dictionary "with a Python tuple" as key in C++?

I currently have some python code I'd like to port to C++ as it's currently slower than I'd like it to be. Problem is that I'm using a dictionary in it where the key is a tuple consisting of an object and a string (e.g. (obj, "word")). How on earth do I write something similar in C++? Maybe my algorithm is horrendous and there is some wa...

Parsing a list of dictionaries passed as a POST parameter

I have a list of python dictionaries that look like this: sandwiches = [ {'bread':'wheat', 'topping':'tomatoes', 'meat':'bacon'}, {'bread':'white', 'topping':'peanut butter', 'meat':'bacon'}, {'bread':'sourdough', 'topping':'cheese', 'meat':'bacon'} ] I want to pass this as a POST parameter to another Django app. What doe...

What's the format of the OpenOffice dictionaries?

Does anyone know what the format of the OpenOffice dictionary files are? As far as I can see there is one word per line, and some flags that presumably tells me something about the word. Here's a couple of lines from the english dictionary as an example: absoluteness/S absorbency/SM abstract/ShTVDPiGY absurdness/S And from the Norweg...

Generic Dictionary - Getting Conversion Error

The following code is giving me an error: // GetDirectoryList() returns Dictionary<string, DirectoryInfo> Dictionary<string, DirectoryInfo> myDirectoryList = GetDirectoryList(); // The following line gives a compile error foreach (Dictionary<string, DirectoryInfo> eachItem in myDirectoryList) The error...

Count items in Dictionary that begin with certain text

I have a dictionary that looks something like this test1 : 123 test2 : 456 another1 : abc test3 : 789 another2 : def How can I get a count of all the items that begin with "test" in c# framework 3.5? ...

Use of unassigned local variable 'dictionary'

I got the error Use of unassigned local variable 'dictionary' despite I assigned the value in the following code: private static void UpdateJadProperties(Uri jadUri, Uri jarUri, Uri notifierUri) { Dictionary<String, String> dictionary; try { String[] jadFileContent; // Create an inst...

How to write the content of a dictionary to a text file?

I have a dictionary object of type Dictionary and trying to use StreamWriter to output the entire content to a text file but failed to find the correct method from the Dictionary class. using (StreamWriter sw = new StreamWriter("myfile.txt")) { sw.WriteLine(dictionary.First()); } I can only retrieve the f...

how to build a index table(python dict like) in python with sqlite3

Suppose I have one string list may have duplicated items: A B C A A C D E F F I want to make a list can assign an unique index for each item, looks like: 1 A 2 B 3 C 4 D 5 E 6 F now I created sqlite3 database with below SQL statement: CREATE TABLE aa ( myid INTEGER PRIMARY KEY AUTOINCREMENT, name STRI...

AutoCompleteBox in Silverlight 4 bound to dictionary - show only values issue

Hello, I have used AutoCompleteBox usercontrol. I have a dictionary of type Dictionary<int,string> which contains ids and names. I want to show only names in the AutoCompleteBox. I can do it with autoCompleteBox1.ItemsSource = dict.Values; My problem is whenever any name is selected I want to retrieve the id associated with it. But ...

reduce python list of objects to dict object.id -> object

Hello! You have list of objects each of them have id property. Here's my way to covert it to dict where keys are ids and values are objects: reduce( lambda x,y: dict(x.items() + { y.id : y}.items()), list, {} ) Suggest better way to do it. ...

How do you add multiple values to a Dictionary Class in VBA 6.5

I am designing a program behind excel and using VBA 6.5. I am having some problems with the built in dictionary object. I understand the basics and have found numerous examples on how to add simple data to them but I'm more concerned with custom objects. My problem: I have an object with several constructors - X, Y, Yf, A, P, etc. Now t...

Fastest way of deleting certain keys from dict in Python

Hi Folks, I'm looking for most fastest/effective way of deleting certain keys in a python dict Here are some options for k in somedict.keys(): if k.startswith("someprefix"): del somedict[k] or dict((k, v) for (k, v) in somedict.iteritems() if not k.startswith('someprefix')) Logically first snippet should be faster o...

C#: optimizing dictionary access (hash in key structures)

So, I need to create a struct in C# that will act as a key into a (quite large) dictionary, will look like this: private readonly IDictionary<KeyStruct, string> m_Invitations; Problem is, I REALLY need a struct to use as a key, because it is only possible to identify entries via two separate data items, where one of them can be a null...

c# How can I define a dictionary that holds different types?

If have the following code. Where you see the XXX I would like to put in an array of type long[]. How can I do this and how would I fetch values from the dictionary? Do I just use defaultAmbience["CountryId"][0] to get the first element? public static Dictionary<string, object> defaultAmbience = new Dictionary<string, object>() ...

How to fill a list view with the contents of Dictonary<string,List<String>> in C#

I've a Dictionary Dictionary<string, List<string>> SampleDict = new Dictionary<string, List<string>>(); I need to fill a listView with the contents of the Dictionary For example the "SampleDict" contains One A B C Two D E F The listView should be filled like S.No Item SubItem ...

Is there a Java equivalent of Python's dictionary display?

In Python I'm using a dictionary display: myAnonDict = {'foo': 23, 'bar': 'helloworld'} Is there an equivalent in Java? [edited 'anonymous dictionary' to read 'dictionary display'] ...