dictionary

StringDictionary To TextFile

Hi There, I am trying to export a stringdictionary to a text file, it has over one million of records, it takes over 3 minutes to export into a textfile if I use a loop. Is there a way to do that faster? Regards ...

Querying a Dictionary with a Lambda Expression

I've created some sample code below, and am trying to use a lambda expression to query against the SoftwareComponents Dictionary. The problem is that the query returns a var of type IGrouping, when what I need to do is further refine the query so that it returns a type of IGrouping where the first string is the SoftwareComponent.Compone...

What Can A 'TreeDict' (Or Treemap) Be Used For In Practice?

I'm developing a 'TreeDict' class in Python. This is a basically a dict that allows you to retrieve its key-value pairs in sorted order, just like the Treemap collection class in Java. I've implemented some functionality based on the way unique indexes in relational databases can be used, e.g. functions to let you retrieve values corre...

C# dictionary value clearing out when I clear list previously assigned to it....why?

Dictionary <string, List <SaleItem>> saleItemNew = new Dictionary<string, List< SaleItem>> (); saleItems = new List <SaleItem> (); saleItemNew.Add("1", saleItems); At this point the list in the Dictionary has values. saleItems.Clear(); However, when I clear out the list previously assigned to it, the dictionary's value List i...

How can I return the last element in a dictionary in C#?

My dictionary: Dictionary<double, string> dic = new Dictionary<double, string>(); How can I return the last element in my dictionary? ...

is there a better way to convert a list to a dictionary in python with keys but no values?

I was sure that there would be a one liner to convert a list to a dictionary where the items in the list were keys and the dictionary had no values. The only way I could find to do it was argued against "Using list comprehensions when the result is ignored is misleading and inefficient. A for loop is better" myList=['a','b','c','d...

C# Moving a Dictionary Into Another File

namespace Webapplication1 { Public Class MyDictionaries : WebApplication1._Default { public static idictionary<string, label> LabelDict = new dictionary<string, label>() { {"name", label1} } } } Hi Everyone. Im trying to separate a dictionary from my code behind file to a separate class file. but when i do this i get a...

Reading NSDictionary Keys from property lists

in my project i'm using a propertyList for maintaining data. the plist file is named "DataBase.plist". the Root for DataBase.plist is a dictionary which contains 5 dictionaries as child items... now the sub Dictionary contains 4 strings out of which one is always a webaddress with key "URL" (Without the quotes).... i'm running the foll...

How to use Comparer for a HashSet

As a result of another question I asked here I want to use a HashSet for my objects I will create objects containing a string and a reference to its owner. public class Synonym { private string name; private Stock owner; public Stock(string NameSynonym, Stock stock) { name=NameSynonym; owner=stock } //...

Add to a dictionary in python?

Hi, Is it possible to add a key to a python dictionary after it has been created? It doesn't seem to have an .add() method... ...

Free or open source multilingual dictionary

I need free or open source multilingual dictionary (ex. en.wiktionary.org) to use in my web projects. Where can I find and download it? ...

Random entry from dictionary

What is the best way to get a random entry from a Dictionary in c#? I need to get a number of random objects from the fictionary to display on a page, however I cannot use: Random rand = new Random(); Dictionary< string, object> dict = GetDictionary(); return dict[rand.Next()]; as dictionaries cannot be accessed by index. Any sugges...

C# refugee seeks a bit of Java collections help

I need to store key/value info in some type of collection. In C#, I'd define a dictionary like this: var entries = new Dictionary<string, int>(); entries.Add("Stop me", 11); entries.Add("Feed me", 12); entries.Add("Walk me", 13); Then I would access the values so: int value = entries["Stop me"]; How do I do this in Java? I've see...

"Adding" Dictionaries in Python?

Hello, My input is two dictionaries that have string keys and integer values. I want to add the two dictionaries so that the result has all the keys of the input dictionaries, and the values are the sum of the input dictionaries' values. For clarity, if a key appears in only one of the inputs, that key/value will appear in the result,...

Python: Best Way to Exchange Keys with Values in a Dictionary?

Hello, I receive a dictionary as input, and would like to to return a dictionary whose keys will be the input's values and whose value will be the corresponding input keys. Values are unique. For example, say my input is: a = dict() a['one']=1 a['two']=2 I would like my output to be: {1: 'one', 2: 'two'} To clarify I would like m...

Python: finding keys with unique values in a dictionary?

Hello, I receive a dictionary as input, and want to return a list of keys for which the dictionary values are unique in the scope of that dictionary. I will clarify with an example. Say my input is dictionary a, constructed as follows: a = dict() a['cat'] = 1 a['fish'] = 1 a['dog'] = 2 # <-- unique a['bat'] = 3 a['...

How to insert values into C# Dictionary on instantiation?

Does anyone know if there is a way I can insert values into a C# Dictionary when I create it? I can, but don't want to, do dict.Add(int, "string") for each item if there is something more efficient like: Dictionary<int, string>(){(0, "string"),(1,"string2"),(2,"string3")}; ...

WPF TextBox Custom Dictionary Support

Has anyone found a workaround yet for getting custom dictionary support working for the built in spellchecking on WPF TextBoxes/RichTextBoxes? We've been probing the spelling stuff with reflector hoping to find where the dictionary entries are coming from, but it's looking very much like it's going to be a COM object.... I know it's not...

data structure for multi-key data?

is there a commonly used data structure for mult-key data? e.g. (key1, key2, ..., keyN) -> value. I used to use dictionaries of dictionaries (in c#), and then wrote my own wrapper on top of this to make the syntax look a bit nicer. but it seems like I still have to write a wrapper for each N-dictionary, where N is the number of keys, sin...

Dictionary class

is it possible to have multiple values for a single key in the java dictionary class?? ...